Removing DNS caching on NGINX proxy pass
If you’re passing hostnames into your nginx’s proxy_pass and made a change to the hostname’s ip address, you might experience times when nginx is still referencing the old ip address despite your DNS TTL having already been expired.
This is because nginx caches the ip of all hostnames resolved in its configuration.
In order to ensure that any IP change is quickly resolved, you should specify a valid period so that nginx will force a cache refresh on its ip storage.
resolver 127.0.0.1 [::1]:5353 valid=1s
This can be done in any of the following context:
http, server, location