我有一个站点使用标准的nginx方法来通过/index.php指导stream量而不pipeurl如何:
location / { try_files $uri $uri/ /index.php?$args; } location ~ \.php$ { fastcgi_pass unix:/run/php/php7.0-fpm.sock; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_index index.php; include fastcgi_params; }
但是我想为一个特定的URL使用一个不同的php-fpm池(但是仍然通过/index.php)。 我可以,我想,在.php $位置块中使用“if”子句,以根据URL使用不同的fastcgi_pass,但不鼓励“if”,所以还有其他方法吗?
您可以使用mapfunction。 例如,在http上下文中定义map如下:
map $request_uri $pool { "/path/to/special" unix:/run/php/special.sock; default unix:/run/php/php7.0-fpm.sock; }
然后在location :
location \.php$ { fastcgi_pass $pool; }
我自己没有testing过这个方法,所以你可能需要调整$poolvariables的内容。