nginx监听相同端口,根据域名请求不同的server
#同时监听相同端口,可以通过匹配server_name来决定最终匹配哪个server
#server1
server {
listen 80;
#server_name localhost;
location /{
rewrite /http://www.baidu.com
}
}
#server2
server {
listen 80;
#uc-center.m.szy.net 在本地的hosts文件解析到127.0.0.1
server_name uc-center.m.szy.net;
location ~*^\/(.*)${
rewrite ^\/(.*)$ http://www.sina.com;
}
}
例如:访问 http://uc-center.m.szy.net 不会因为server1的配置,而导致跳转到“百度首页”。nginx会优先匹配
相关推荐
nginxs 2020-11-14
Guanjs0 2020-11-13
小木兮子 2020-11-11
yserver 2020-11-11
ssihc0 2020-11-11
windle 2020-11-10
HanksWang 2020-11-10
liuchen0 2020-11-10
Freshairx 2020-11-10
ccschan 2020-11-10
liwf 2020-11-10
Guanjs0 2020-11-09
AderStep 2020-11-09
zrtlin 2020-11-09
mqfcu 2020-11-10
windle 2020-10-29