我正在尝试配置我的 Apache Web 服务器以使用
flushpackets=on
和 php-fpm FCGI 后端,但我希望此设置仅应用于特定 URL。
我当前的 php-fpm 配置是:
<IfModule !mod_php5.c>
<IfModule !mod_php7.c>
# Enable http authorization headers
SetEnvIfNoCase ^Authorization$ "(.+)" HTTP_AUTHORIZATION=$1
<FilesMatch \.(php|phar)$>
SetHandler "proxy:unix:/run/php-fpm/www.sock|fcgi://localhost"
</FilesMatch>
<Proxy "fcgi://localhost" enablereuse=on flushpackets=on max=10>
ProxySet timeout=100
</Proxy>
</IfModule>
</IfModule>
这会为所有请求设置刷新数据包,但我希望它仅针对特定网址启用,例如 /endpoint_1/
要将
flushpackets=on
仅应用于特定 URL,请使用 <Location>
像这样:
<IfModule !mod_php5.c>
<IfModule !mod_php7.c>
# Enable http authorization headers
SetEnvIfNoCase ^Authorization$ "(.+)" HTTP_AUTHORIZATION=$1
<FilesMatch \.(php|phar)$>
SetHandler "proxy:unix:/run/php-fpm/www.sock|fcgi://localhost"
</FilesMatch>
<Proxy "fcgi://localhost/endpoint_1">
ProxySet enablereuse=on
ProxySet flushpackets=on
ProxySet max=10
ProxySet timeout=100
</Proxy>
<Proxy "fcgi://localhost/general">
ProxySet enablereuse=on
ProxySet flushpackets=off
ProxySet max=10
ProxySet timeout=100
</Proxy>
<Location /endpoint_1/>
ProxyPass "fcgi://localhost/endpoint_1"
ProxyPassReverse "fcgi://localhost/endpoint_1"
</Location>
<Location />
ProxyPass "fcgi://localhost/general"
ProxyPassReverse "fcgi://localhost/general"
</Location>
</IfModule>
</IfModule>