子目录的特定 fpm 池
Specific fpm pool for a subdirectory
我试图让我的 nginx.conf 简单,但我无法让特定文件夹的 .php 文件使用与全局文件不同的 fpm。
我目前的配置是
location ~ \.php$ {
# Test for non-existent scripts or throw a 404 error
# Without this line, nginx will blindly send any request ending in .php to php-fpm
try_files $uri =404;
include /etc/nginx/fastcgi.conf;
fastcgi_pass unix:/run/php-fpm.socket;
}
location /postfixadmin/ ~ \.php$ {
# Test for non-existent scripts or throw a 404 error
# Without this line, nginx will blindly send any request ending in .php to php-fpm
try_files $uri =404;
include /etc/nginx/fastcgi.conf;
fastcgi_pass unix:/run/php-fpm.vmail.socket;
}
我正在尝试让子文件夹 postfixadmin(及以下)在涉及 .php 文件时使用 /run/php-fpm.vmail.socket,但在其他情况下全局使用其他站点,使用 /run/php-fpm.socket。是否可以将此特殊规则仅应用于单个子文件夹?
不幸的是,这会破坏 nginx,它不会加载。我已经尝试过其他配置,但无论我到目前为止尝试过什么,最终要么没有加载,要么使用全局套接字。
尝试将此作为第二个位置:
location ~ /postfixadmin/.*\.php$ {
...
}
或者您可以尝试嵌套位置:
location ~ \.php$ {
location ^/postfixadmin/ {
try_files $uri =404;
include /etc/nginx/fastcgi.conf;
fastcgi_pass unix:/run/php-fpm.vmail.socket;
}
try_files $uri =404;
include /etc/nginx/fastcgi.conf;
fastcgi_pass unix:/run/php-fpm.socket;
}
我试图让我的 nginx.conf 简单,但我无法让特定文件夹的 .php 文件使用与全局文件不同的 fpm。
我目前的配置是
location ~ \.php$ {
# Test for non-existent scripts or throw a 404 error
# Without this line, nginx will blindly send any request ending in .php to php-fpm
try_files $uri =404;
include /etc/nginx/fastcgi.conf;
fastcgi_pass unix:/run/php-fpm.socket;
}
location /postfixadmin/ ~ \.php$ {
# Test for non-existent scripts or throw a 404 error
# Without this line, nginx will blindly send any request ending in .php to php-fpm
try_files $uri =404;
include /etc/nginx/fastcgi.conf;
fastcgi_pass unix:/run/php-fpm.vmail.socket;
}
我正在尝试让子文件夹 postfixadmin(及以下)在涉及 .php 文件时使用 /run/php-fpm.vmail.socket,但在其他情况下全局使用其他站点,使用 /run/php-fpm.socket。是否可以将此特殊规则仅应用于单个子文件夹?
不幸的是,这会破坏 nginx,它不会加载。我已经尝试过其他配置,但无论我到目前为止尝试过什么,最终要么没有加载,要么使用全局套接字。
尝试将此作为第二个位置:
location ~ /postfixadmin/.*\.php$ {
...
}
或者您可以尝试嵌套位置:
location ~ \.php$ {
location ^/postfixadmin/ {
try_files $uri =404;
include /etc/nginx/fastcgi.conf;
fastcgi_pass unix:/run/php-fpm.vmail.socket;
}
try_files $uri =404;
include /etc/nginx/fastcgi.conf;
fastcgi_pass unix:/run/php-fpm.socket;
}