【发布时间】:2011-12-23 00:41:39
【问题描述】:
我最近设置了一个 Nginx 服务器来托管 wordpress 安装,并在服务器前使用 Varnish 作为反向代理。 Varnish 在 80 端口上运行,所以我设置了 Nginx 来监听 80 并重定向。不幸的是,在重定向时,端口 8080 被附加到 nginx 请求中。
包括port_in_redirect off 似乎是解决此问题的一般方法,但它似乎对我不起作用。我在下面附上了/sites-enabled/default 配置。我做错什么了吗?! php 重定向似乎工作正常,它只是在location /失败的地方。
/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:nginx版本:nginx/1.0.9
【问题讨论】: