问题原文
原帖链接 · Daniel Müller · CC BY-SA 3.0
I searched for a while online but couldn't succeed. My problem is as follows:
I want to use different php-fpm pools in one nginx vhost based conditionally on the nature of the request but couldn't find a way to configure the location ~ \.php$ {...} part of my vhost config to support two different worker pools.
Only solution I figured out is redirecting the web request to another nginx site.
Thank you in advance
已采纳解答
原帖链接 · Tero Kilkanen · CC BY-SA 3.0
You can work along the following principle:
set $upstream /path/to/defaultfpm-socket;
location /first {
set $upstream /path/to/fpm1-socket;
}
location /second {
set $upstream /path/to/fpm2-socket;
}
fastcgi_pass $upstream;
So, here we set the $upstream variable to the PHP5-FPM socket we want to use depending on the location (part of the URI). We then use the variable with fastcgi_pass to pass the request to that PHP5-FPM instance.
location rules can use normal nginx matching rules, like regex, prefix etc. matching. It is a good idea to set a default value so that requests are always parsed.
You need to also include other FastCGI statements in the configuration.
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
