代码解释
1.1 http:www.baidu.test.com默认是80,访问“/”利用反向代理,然后访问本地8083;
1.2 8083代表本地的前端工程访问地址,前端需要访问后台数据,”/”,继续代理到后台地址9803;
1.3 这样就做到了只要开通80端口就可以完成多个端口访问。
1.4 root配置可以是绝对路径,也可是相对路径。
server {
listen 80;
server_name www.baidu.test.com;#你要填写的域名,多个用逗号隔开
location / {
proxy_pass http://localhost:8083;
proxy_set_header host $host;
proxy_set_header x-real-ip $remote_addr;
proxy_set_header x-forwarded-for $proxy_add_x_forwarded_for;
root /app/esop_web/esopschool;
index index.html;
try_files $uri $uri/ /index.html;
}
location /rest{
proxy_pass http://localhost:9803;
proxy_set_header host $host;
proxy_set_header x-real-ip $remote_addr;
proxy_set_header x-forwarded-for $proxy_add_x_forwarded_for;
}
}以上就是nginx反向代理怎么实现多端口映射的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号