Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question

2 Answers 2

up vote 1 down vote accepted

I found solution here:

http://forum.nginx.org/read.php?2,238835,238899#msg-238899

location / {
set $backend "m1.local";
proxy_pass http://$backend;
}
share|improve this answer

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.

share|improve this answer
    
Yep. I sure you right, but it is not helps. This ip changed not by me, by another proccess, so I never know when do "reload". –  Korjavin Ivan Sep 5 '13 at 12:03

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.