nginx 配置针对所有请求执行跳转
原配置
location / {
index index.html index.htm;
add_header X-Location /;
try_files $uri /index.php$is_args$args;
fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
#include fastcgi.conf;
include fastcgi_params;
}
修改为
location / {
index index.html index.htm;
add_header X-Location /;
#try_files $uri /index.php$is_args$args;
proxy_pass http://www.testk.com;
#fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
#include fastcgi.conf;
include fastcgi_params;
}
执行了proxy_pass后fastcgi_pass unix:/tmp/php-cgi.sock;这个配置就不能设置了,有的地方是php-cgi.sock有的地方是php-fpm.sock。
我这边出现403的原因使proxy_pass和fastcgi_pass冲突了,如果需要fastcgi_pass的配置,应该在代理的目标服务器中配置。
如果只是做代理的话,其他配置也的确十分没必要。