tmtongming 2014-11-27
nginx默认监听80端口,但有些时候80端口要分配给其他应用的,所以要把nginx默认的80端口改掉,修改的文件位置在nginx安装目录下的conf文件下的nginx.conf。
nginx的默认配置为:
server {
listen 80;
server_name static.yisheng.com;
location / {
root D:/aaa;
access_log off;
#expires 1h;
}
}换成监听81端口:
server {
listen 81;
server_name static.yisheng.com;
location / {
root D:/aaa;
access_log off;
#expires 1h;
proxy_set_header Host $host:81;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Via "nginx";
}
}代码中的红色标记了不同之处。
当然了,在项目使用的话要把http://static.yisheng.com换成带有端口的地址:http://static.yisheng.com:81