Nginx 项目映射到端口

当某台服务器只能开放一个对外的80端口时,通过nginx转发可以实现使用项目路径对其他应用进行访问。

nginx如下配置:

location /zabbix/ {
proxy_pass http://server3:4000/;
proxy_set_header Host $host:$server_port;
}

location /rabbitmq/ {
proxy_pass http://172.18.192.10:15672/;
proxy_set_header Host $host:$server_port;
}

zabbix实际访问的路径为:http://ip:4000

但是4000端口没有开放,只开放了80端口,通过以上nginx的配置,我们可以访问:http://ip:80/zabbix,就可以访问到zabbix的页面了,rabbitmq也是如此。

posted @ 2020-08-07 09:41  Leo_dreasky  阅读(1467)  评论(0编辑  收藏  举报