nginx反向代理之多端口映射的实现
代码解释
1.1http:www.baidu.test.com默认是80,访问“/”利用反向代理,然后访问本地8083;
1.28083代表本地的前端工程访问地址,前端需要访问后台数据,”/”,继续代理到后台地址9803;
1.3这样就做到了只要开通80端口就可以完成多个端口访问。
1.4root配置可以是绝对路径,也可是相对路径。
server{
listen80;
server_namewww.baidu.test.com;#你要填写的域名,多个用逗号隔开
location/{
proxy_passhttp://localhost:8083;
proxy_set_headerHost$host;
proxy_set_headerX-Real-IP$remote_addr;
proxy_set_headerX-Forwarded-For$proxy_add_x_forwarded_for;
root/app/esop_web/esopschool;
indexindex.html;
try_files$uri$uri//index.html;
}
location/rest{
proxy_passhttp://localhost:9803;
proxy_set_headerHost$host;
proxy_set_headerX-Real-IP$remote_addr;
proxy_set_headerX-Forwarded-For$proxy_add_x_forwarded_for;
}
}
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持毛票票。