当nginx部署在不是80端口上出现的问题的解决办法

由于最近的一个报表统计项目要部署在linux服务器上,而80端口已经被业务系统占用,我就将报表系统部署在4000商品上,来代理 后端的4001和4002的两个mongrel进程,我的配置如下:

 

写道
user root;
worker_processes 1;




events {
worker_connections 1024;
}


http {
include mime.types;
default_type application/octet-stream;



sendfile on;
#tcp_nopush on;

#keepalive_timeout 0;
keepalive_timeout 65;

upstream mongrel {
server 192.168.0.54:4001;
server 192.168.0.54:4002;
}

gzip on;

server {
listen 4000;
server_name 192.168.0.54;



root /home/qichunren/works/zhao_report/public;

location / {
proxy_pass http://mongrel;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}


location ~ .*\.(js|jpg|JPG|jpeg|JPEG|css|bmp|gif|GIF|png)$ {
access_log off;
}


}

}

 

我访问192.168.0.54:4000是正常的,可是当前登录成功后,却总是跳转到192.168.0.54 ,我在网上找了许多资料,最后发现在

proxy_set_header Host $host; 后面加上4000端口就可以了。

写道
location / {
proxy_pass http://mongrel;
proxy_redirect off;
proxy_set_header Host $host :4000;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

 

问题就这样解决了。

你可能感兴趣的:(nginx,linux,css,Access)