php 如何在apache FCGI中设置flushpackets=on仅用于选定的url

sauutmhj  于 2023-10-15  发布在  PHP
关注(0)|答案(1)|浏览(129)

我试图配置我的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>

这将为所有请求设置flushpackets,但我希望它只为特定的URL启用,如/endpoint_1/

iyfjxgzm

iyfjxgzm1#

要将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/general"
    </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>

相关问题