我最近设置了一个Nginx服务器来托管wordpress安装,并使用Varnish作为服务器前面的反向代理. Varnish在端口80上运行,因此我将Nginx设置为侦听80并重定向.不幸的是,在重定向时,端口8080附加到了Nginx请求.
包括port_in_redirect off似乎是解决此问题的一般方法,但它似乎不适用于我.我已经在下面附加了/ sites-enabled / default配置.我做错什么了吗? PHP重定向似乎工作正常,仅在失败的位置/.
/ sites-enabled / default:
server {
listen 8080 default;
server_name "" xxx.xxx.xxx.xxx; #just using IP here (no domain yet)
port_in_redirect off;
server_name_in_redirect off;
access_log /var/log/Nginx/localhost.access.log;
location / {
root /var/www/site/html/;
index index index.PHP;
try_files $uri/ $uri /index.PHP?q=$uri&$args;
}
location ~ .PHP${
fastcgi_split_path_info ^(.+.PHP)(.*)$;
fastcgi_pass backend;
fastcgi_index index.PHP;
fastcgi_param SCRIPT_FILENAME /var/www/site/html/$fastcgi_script_name;
include fastcgi_params;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_intercept_errors on;
fastcgi_ignore_client_abort off;
fastcgi_connect_timeout 60;
fastcgi_send_timeout 180;
fastcgi_read_timeout 180;
fastcgi_buffer_size 128k;
fastcgi_buffers 4 256k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
fastcgi_param SERVER_PORT 80;
}
location ~ /.ht {
deny all;
}
location ~ /.git {
deny all;
}
location ~ /.svn {
deny all;
}
}
upstream backend {
server 127.0.0.1:9000;
}
Nginx.conf:
user www-data;
worker_processes 1;
error_log /var/log/Nginx/error.log debug;
pid /var/run/Nginx.pid;
events {
worker_connections 1024;
multi_accept on;
}
http {
include /etc/Nginx/mime.types;
access_log /var/log/Nginx/access.log;
sendfile on;
tcp_nopush off;
keepalive_timeout 30;
tcp_nodelay on;
gzip on;
gzip_proxied any;
gzip_disable "MSIE [1-6]\.(?!.*SV1)";
gzip_types text/plain text/css application/x-javascript text/xml application/xml application/xml+RSS text/javascript;
include /etc/Nginx/conf.d/*.conf;
include /etc/Nginx/sites-enabled/*;
}
最佳答案
原文链接:/nginx/532209.html