Just checking if anyone had similar issues when nginx is used as a reverse proxy:
I basically have one app A running nginx and using proxy_pass to forward /api requests to another app B using app-name.internal as host.
What I noticed is if I redeploy app B and thus its ipv6 address is now different; nginx in app A seems to still be using the stale ipv6 address from the previous instance. I checked with dig in the nginx instance that the ipv6 address is up to date but it seems that likely nginx in this case is caching the dns lookup result.
Any recommendation of how to handle this, should the deploy of app B just restart app A to clear cache or is there a better way to handle this.
@ignoramous I don’t think the TTL matters if nginx itself is caching the DNS lookup result right ? and that’s what I’m suspecting here because I get the right result when using dig but I see in the access logs that nginx is using a different IP so it must be something in the nginx handling of DNS lookup which I suspect it does cache lookups just like JVMs etc …
Though now that I looked at nginx docs I think Module ngx_http_core_module might get around my problem if I set the resolver to fdaa::3, forcing nginx to go through the fly dns resolver on every request using the same 5s TTL.
I’ll try that and reply back if it works
@amine you can also add it to the http level config so you don’t need to apply it to every server config, that’s what we do since we handle various subdomains using the same fly app.
http {
....
# Use NGINX's non-blocking DNS resolution
resolver [fdaa::3]:53;
....
}