我最近决定尝试在一个Droplet上尝试Nginx,但我仍然需要将路径http://tld.com/guides的proxy_pass传递给另一个托管wordpress的Apache droplet
这是我的proxypass conf:
location /guides {
rewrite ^/guides/(.*)$ /$1 break;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
proxy_pass http://droplet_private_ip:80;
proxy_redirect off;
}
这就是Nginx将所有wordpress的php文件重定向到fpm,我认为这是由于这个
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
# NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
# With php5-cgi alone:
#fastcgi_pass 127.0.0.1:9000;
# With php5-fpm:
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
有没有办法排除来自/ guide的所有请求被本地fpm执行?
答案 0 :(得分:0)
我已经修好了。以防有人遇到同样的问题。这解决了我的问题
location ~* ^((?!\/guides)(.+)\.php)$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
# NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
# With php5-cgi alone:
#fastcgi_pass 127.0.0.1:9000;
# With php5-fpm:
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
这部分完全
location ~* ^((?!\/guides)(.+)\.php)$ {
确保来自/ guides的所有.php文件不受fpm
的影响