查看错误日志:
2021/06/09 10:22:25 [error] 24#24: *11 connect() failed (111: Connection refused) while connecting to upstream, client: 192.168.50.2, server: localhost, request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:8084/", host: "192.168.50.188"
2021/06/09 10:22:25 [warn] 24#24: *11 upstream server temporarily disabled while connecting to upstream, client: 192.168.50.2, server: localhost, request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:8084/", host: "192.168.50.188"
基本判定是nginx链接不上指定端口 http://127.0.0.1:8084/
问题排查
在本机 执行
curl http://127.0.0.1:8084/
正常返回
查询端口进程
所以排除本身tomcat挂掉的问题
注意到一句话:
特别注意的是,在location指令中使用正则表达式后,proxy_pass后面的代理路径不能含有地址链接,也就是不能写成http://192.168.12.130:8080/,或者类似http://192.168.12.130:8080/jsp的形式。在location指令不使用正则表达式时,没有此限制。
查看配置 并没有使用正则表达式 排除这个问题
灵光一现,nginx 和 tomcat 都是docker 容器搭载的,所以是nginx容器内部链接不到tomcat容器才是正确的思路,所以进入nginx容器排查链接问题发现确实访问不通
这里修改为宿主机的ip地址
最终测试 成功解决问题