I have nginx redirect like:
server {
listen 127.0.0.1:80;
server_name myname.local
location / {
proxy_pass http://m1.local:8080;
}
}
}
Works good.
But after ip address for m1.local was changed - nginx start to return "bad gateway".
Looks like it has caching ip address for m1.local.
nslookup m1.local from nginx computer show right value, and restart nginx repair the situation.
How to say nginx that it shouldn't cache ip's for dns name?
Nginx is doing these name lookups on start, and then it only keeps the IPs. This means that it won't even keep the names in memory during run time to look them up again.
If you change the DNS entries that you refer to in the Nginx conf, you can do an
nginx -s reload
to make it reload the config, this includes redoing the DNS lookups.I found solution here:
http://forum.nginx.org/read.php?2,238835,238899#msg-238899