Nginx报upstream timed out错误

前两天给客户部署生产环境,客户提供的是windows服务,我们的系统是前后台分离的,前台使用nginx容器,我按正常思路部署好服务后,前台页面正常显示,但是前台连接后台时,时好时坏,经常连不到后台服务器,但是后台正常提供服务,经过简单分析,应该是nginx的问题。看了下nginx的日志,发现error.log果然有错误抛出。

2018/09/20 16:41:47 [error] 2280#4160: *15 upstream timed out (10060: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond) while connecting to upstream, client: 127.0.0.1, server: 127.0.0.1, request: "POST /*****/pc/sys/login HTTP/1.1", upstream: "http://[::1]:8080/*****/pc/sys/login", host: "localhost", referrer: "http://localhost/loginOld"
2018/09/20 16:44:09 [error] 2280#4160: *47 upstream timed out (10060: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond) while connecting to upstream, client: 127.0.0.1, server: 127.0.0.1, request: "POST /*****/pc/sys/login HTTP/1.1", upstream: "http://[::1]:8080/*****/pc/sys/login", host: "127.0.0.1", referrer: "http://127.0.0.1/loginOld"
2018/09/20 16:45:40 [error] 2280#4160: *51 upstream timed out (10060: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond) while connecting to upstream, client: 127.0.0.1, server: 127.0.0.1, request: "POST /*****/pc/sys/login HTTP/1.1", upstream: "http://[::1]:8080/*****/pc/sys/login", host: "127.0.0.1", referrer: "http://127.0.0.1/loginOld"

我把重点标红了,大家看到是不是很奇怪,地址里怎么会有[::1] 这样的地址呢,其实谜底在这里

现在ip地址有两种ipv4和ipv6,区别我就不讲了,大家可以问度娘,关键是现在很多操作系统默认使用IPV6了,如果是这样的话localhost就不好使了,他会被转换成http://[::1]:这种地址。查看nginx配置文件

把所有localhost改为127.0.0.1,完美解决问题

猜你喜欢

转载自blog.csdn.net/hczjb/article/details/82796494
今日推荐