Apache 模块 mod_proxy_scgi

Description: mod_proxy的 SCGI 网关模块
Status: Extension
Module Identifier: proxy_scgi_module
Source File: mod_proxy_scgi.c
Compatibility: 在 2.2.14 版和更高版本中可用

Summary

该模块需要 mod_proxy的服务。它为SCGI 协议,版本 1提供支持。

因此,为了获得处理 SCGI 协议的能力,服务器中必须存在mod_proxymod_proxy_scgi

Warning

在拥有保护您的服务器之前,不要启用代理。开放式代理服务器对您的网络和整个 Internet 都是危险的。

Examples

请记住,为了使以下示例起作用,您必须启用mod_proxymod_proxy_scgi

Simple gateway

ProxyPass "/scgi-bin/" "scgi://localhost:4000/"

除了上面列出的代理模块之外,平衡网关还需要mod_proxy_balancer和至少一个负载平衡器算法模块,例如mod_lbmethod_byrequestsmod_lbmethod_byrequests是默认值,将用于此示例配置。

Balanced gateway

ProxyPass "/scgi-bin/" "balancer://somecluster/"
<Proxy "balancer://somecluster">
    BalancerMember "scgi://localhost:4000"
    BalancerMember "scgi://localhost:4001"
</Proxy>

Environment Variables

除了控制mod_proxy行为的配置指令外,环境变量还可以控制 SCGI 协议提供程序:

ProxySCGIInternalRedirect Directive

Description: 从后端启用或禁用内部重定向响应
Syntax: ProxySCGIInternalRedirect On|Off|Headername
Default: ProxySCGIInternalRedirect On
Context: 服务器配置,虚拟主机,目录
Status: Extension
Module: mod_proxy_scgi
Compatibility: Headers 名称功能在版本 2.4.13 和更高版本中可用

ProxySCGIInternalRedirect使后端可以在内部将网关重定向到其他 URL。此功能起源于mod_cgi,如果响应状态为OK(200)并且响应包含Location(或配置的备用 Headers)并且其值以斜杠(/)开头,则该函数在内部重定向响应。该值被解释为 Apache httpd 内部重定向到的新本地 URL。

mod_proxy_scgi在这方面与mod_cgi相同,除了可以关闭该功能或指定使用Location以外的 Headers。

Example

ProxySCGIInternalRedirect Off

# Django and some other frameworks will fully qualify "local URLs"
# set by the application, so an alternate header must be used.
<Location /django-app/>
    ProxySCGIInternalRedirect X-Location
</Location>

ProxySCGISendfile Directive

Description: 启用对 X-Sendfile 伪响应 Headers 的评估
Syntax: ProxySCGISendfile On|Off|Headername
Default: ProxySCGISendfile Off
Context: 服务器配置,虚拟主机,目录
Status: Extension
Module: mod_proxy_scgi

ProxySCGISendfile指令使 SCGI 后端可以让文件直接由网关提供服务。这对于提高性能很有用-httpd 可以使用sendfile或其他优化,如果文件来自后端套接字,则不可能。此外,文件内容不会发送两次。

ProxySCGISendfile参数确定网关行为:

Example

# Use the default header (X-Sendfile)
ProxySCGISendfile On

# Use a different header
ProxySCGISendfile X-Send-Static
首页