云服务器 Docker Nginx代理 状态502 connect() failed (113: No route to host) while connecting to upstream

编程入门 行业动态 更新时间:2024-10-11 13:30:26

云服务器 Docker Nginx代理 <a href=https://www.elefans.com/category/jswz/34/1771386.html style=状态502 connect() failed (113: No route to host) while connecting to upstream"/>

云服务器 Docker Nginx代理 状态502 connect() failed (113: No route to host) while connecting to upstream

起因

最近用腾讯云和华为云服务器(CentOS7.6)的Docker Nginx做代理的时候总是不能访问,远程访问状态是502。用本地curl命令测试是可以访问的,经过一番折腾,原来是防火墙没有开端口;真是汗颜(我记得以前用的阿里云不用开内部防火墙端口啊)。

Nginx error.log如下:

[error] 19#19: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 110.184.64.195, server: 127.0.0.1, request: "GET /web/api/regions/2 HTTP/1.1", upstream: "http://127.0.0.1:8889/web/api/regions/2", host: "xxx..."[error] 19#19: *7 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 172.17.0.1, server: localhost, request: "GET /web/api/regions/2 HTTP/1.1", upstream: "http://192.168.0.87:8889/web/api/regions/2", host: "xxx..."[error] 19#19: *9 connect() failed (113: No route to host) while connecting to upstream, client: 110.184.64.195, server: localhost, request: "GET /web/api/regions/2 HTTP/1.1", upstream: "http://192.168.0.87:8889/web/api/regions/2", host: "xxx..."

解决办法

开放防火墙端口

# 开放8889端口
firewall-cmd --zone=public --add-port=8889/tcp --permanent# 配置立即生效
firewall-cmd --reload

更多推荐

云服务器 Docker Nginx代理 状态502 connect() failed (113: No route to host) while connect

本文发布于:2024-02-07 09:31:03,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1755916.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:状态   服务器   Nginx   connect   Docker

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!