nginx同一端口实现不同域名对应不同静态页,并转发

2018-02-03 10:25:37来源:https://www.jianshu.com/p/c798dac9b2ed作者:helei在路上人点击

分享

代码配置详情nginx.conf


`  server {
listen 80;
server_name ad.bjhxsm.net;
#charset koi8-r;
#access_log logs/host.access.log main;
location /page {
root /usr/local;
index index.html index.htm;
}
location / {
proxy_pass http://127.0.0.1:8081;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}

server {
listen 80;
server_name ad.cnqywin.com;
#charset koi8-r;
#access_log logs/host.access.log main;
location /page {
root /usr/local;
index index.html index.htm;
}
location / {
proxy_pass http://127.0.0.1:8081;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
`


邮箱:ithelei@sina.cn
GoodLuck




微信扫一扫

第七城市微信公众平台