9 months ago
We have an nginx container running that does a proxy_pass to a website using the private networking address, but anytime the website redeploys I have to restart the nginx container. I believe this might be because the private ip of the website service changes between deployments and nginx has cached the dns resolution to the previous ip of the website. Is there a way to prevent this?
5 Replies
9 months ago
Hello,
You are exactly correct, NGINX is caching the DNS for the private domain.
And indeed the IPs for the private domains will change every time you redeploy the given service.
There is no way to have static IPs for the private network, so you have a few options -
- Use Caddy, Caddy will do a DNS lookup for every request.
- Configure NGINX to re-resolve every 1s -
server {
listen 8080;
server_name localhost;
resolver [fd12::10] ipv6=on valid=1s; // Internal DNS server
set $proxy_pass_url http://api.railway.internal:8080;
location / {
proxy_pass $proxy_pass_url;
}
}
Status changed to Awaiting User Response railway[bot] • 9 months ago
8 months ago
Thanks for confirming my suspicions brody, Caddy was already on our list to evaluate so so we'll give that a try.
Status changed to Awaiting Railway Response railway[bot] • 9 months ago
Status changed to Awaiting User Response railway[bot] • 9 months ago
8 months ago
We got it setup and Caddy works great, thanks for the suggestion
Status changed to Awaiting Railway Response railway[bot] • 8 months ago
8 months ago
That's great, I'm happy to hear it!, please let me know if you need anything else.
Status changed to Awaiting User Response railway[bot] • 8 months ago
Status changed to Solved brody • 8 months ago