Nginx reverse proxy to another server, connection timeout after domain name resolution IP change

When nginx mesos-dns is combined

location ~ .* {
        pro xy_pass http://www.example.com/;
        proxy_set_header X-Real-IP $remote_addr;
}

Previously, www.example.com was resolved to IP A. Since the back-end server IP was changed to B, and the domain name resolution was also changed to B, Nginx now has Gateway Time-out errors such as 502 or 504 when accessing it again. Check nginx The error.log (below) found that the IP connected to nginx is still the previous IP A, and it will be normal unless Nginx is restarted.

2014/11/16 12:03:41 [error] 9531#0: *12264 upstream timed out (110: Connection timed out) while connecting to upstream, client: 14.209.152.128, server: 127.0.0.1, request: "GET / HTTP/1.0", upstream: "http://A/", host: "127.0.0.1"

 

 

It is best to specify the proxy domain name and ip pair in the hosts, that is, manually add the resolution, otherwise it is uncertain when the DNS resolution will change, and if there are many proxy websites, as long as there is a set of domain name DNS resolution failure, nginx will stop running

 

 

 Using a domain name is the worst way. It will cause various problems, such as slowness, instability and so on.

Don't be lazy, use ip honestly, and update the conf configuration after updating the ip. Or use the hosts file.

 

 

https://www.oschina.net/question/197670_184301 

 

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326490201&siteId=291194637
Recommended