type
status
date
slug
summary
tags
category
icon
password
问题描述
需求描述
我在PC上直接访问
localhost:9080的时候,能通过nginx的负载均衡功能随机访问部署好的服务集群。测试环境
使用bridge部署pointer-ce,对外端口39999
使用bridge部署nginx-ui,对外端口58080
使用bridge部署3个wol-server,对外端口9090、9091、9092
nginx-ui.conf默认配置如下已验证上述服务通过
localhost+端口号能正常访问,直接访问localhost:9000 为无法打开测试情况
为简单化处理问题,暂时不使用负载均衡。
在
nginx-ui.conf的基础上直接添加新的location路径改成/test并代理localhost:9080,访问localhost:9080时被拒绝。而使用浏览器打开localhost:58080/test能正常访问到wol-server。新建
nginx.conf,添加location路径/并监听9080,proxy_pass代理任意wol-server地址,能成功访问localhost:9080代理后的wol-server,实际上无法打开。问题分析
本以为新建
nginx.conf就应该能直接打开localhost:9080 代理后的wol-server ,却变成了nginx-ui管理页面地址/test才能正常访问。经以上尝试后,一直在纠结是不是80被占用导致的,没能想明白其中的逻辑。经过排查发现,容器nginx-ui的默认监听端口是
80且反向代理端口是9000,而pointer-ce的默认端口恰好就是9000 。此时才发现pointer-ce和nginx-ui都是在bridge模式下工作,pointer-ce的对外地址是
localhost:58080 ,nginx-ui的对外地址是localhost:39999 ,而proxy_pass的localhost:9000 完全没有提供服务,也就是说配置的内容都没对localhost 生效。解决办法
docker使用bridge部署pointer-ce,已避开9000端口,保持不变。
docker使用host部署nginx-ui,此时容器日志会一直显示80端口被占用的报错。访问
localhost:9000能打开nginx-ui的管理页面,可以看到nginx服务启动失败。修改
nginx-ui.conf的默认配置:重载或重启nginx服务,此时打开
localhost:9080 能成功访问wol-server服务。参考文章
无
- Author:always1ov
- URL:https://always1ov.com/article/%E5%88%9D%E6%AC%A1%E4%BD%BF%E7%94%A8nginx-ui%E5%AE%9E%E7%8E%B0%E5%8F%8D%E5%90%91%E4%BB%A3%E7%90%86%E6%97%B6%E9%81%87%E5%88%B0%E7%9A%84%E9%97%AE%E9%A2%98
- Copyright:All articles in this blog, except for special statements, adopt BY-NC-SA agreement. Please indicate the source!
Relate Posts
