Linux-024-Centos Nginx 代理配置:不同端口代理不同服务
创建如下所示的目录,并在相应的文件中写入相应的内容,简单模拟三个不同的服务
在 Nginx 的配置文件中添加所示的代理配置
server { listen 8081; server_name localhost; location / { root /data/servers/8081; index index.html index.htm; } } server { listen 8082; server_name localhost; location / { root /data/servers/8082; index index.html index.htm; } } server { listen 8083; server_name localhost; location / { root /data/servers/8083; index index.html index.htm; } }
nginx.conf 修改后的配置样式如下所示:
检查配置无误后,重新加载配置文件
nginx -t
nginx -s reload
使用 curl 访问服务,如下所示
说明 nginx 配置代理:不同端口代理不同服务配置已生效
欢迎 【 留言 || 关注 || 打赏 】 。您的每一份心意都是对我的鼓励和支持!非常感谢!欢迎互加,相互交流学习!
作者:范丰平,本文链接:https://www.cnblogs.com/fengpingfan/p/14512304.html
Copyright @范丰平 版权所有,如需转载请标明本文原始链接出处,严禁商业用途! 我的个人博客链接地址:http://www.cnblogs.com/fengpingfan
![](https://images.cnblogs.com/cnblogs_com/fengpingfan/2153325/o_220506115434_gzgqrb.png)