Apache + PHP-FPM Set proxy timeout only for a specific path

I have Apache 2.4 with PHP 5.5 without using php_mod, but with PHP-FPM and mod_proxy_fcgi, so I added the following to vhost:

ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:7000/home/var/www/site/$1 

This worked well, but when I had problems with timeouts, I added the following code to fix this problem in the vhost file:

 <Proxy fcgi://127.0.0.1:7000> ProxySet timeout=3600 </Proxy> ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:7000/home/var/www/site/$1 

However, I would like to add this timeout only to the administration panel of the www.site.com/admin/xxx website. I tried to add a location tag as shown below, but it did not work (Apache does not work when restarting).

 <LocationMatch ^/admin/.*\.php(/.*)?$> <Proxy fcgi://127.0.0.1:7000> ProxySet timeout=3600 </Proxy> </LocationMatch > ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:7000/home/var/www/site/$1 

First, is this possible? Then what will be the correct syntax?

Thanks so much for your time.

+6
source share
1 answer

Just use the proxy wildcard with /admin/*

While this will allow ANY script under the administrator to run with the settings set, the administrator (and I assume that to log in) the wall should not be a problem.

 <Proxy "fcgi://127.0.0.1:7000/home/var/www/site/admin/*"> ProxySet timeout=3600 </Proxy> 

Use ProxySet outside the Proxy directive

ProxySet in the Proxy directive can be used without defining url / balancer / worker. But you should still use ProxySet in the Location directive.

 <LocationMatch ^/admin/.*\.php(/.*)?$> ProxySet "fcgi://127.0.0.1:7000" timeout=3600 </LocationMatch> 

If apache still does not work at startup, check the apache logs or run strace -Ff apachectl start to find the problem, it might just be a bug in this version of apache.

However, I strongly suspect that your LocationMatch expression ^/admin/.*\.php(/.*)?$ is causing Apache to fail.

0
source

Source: https://habr.com/ru/post/981270/


All Articles