dar
dar

Reputation: 31

The Nginx reverse proxy does not reach the app via the internal route after restarting

We have the following setup: nginx buildpack as reverse proxy with proxy_pass set to an internal route *.apps.internal. The setup works fine until the app to which the internal route leads restarts. Then we have the problem that the app gets a new internal IP address and the internal DNS does not immediately resolve the internal route *.apps.internal to the new IP address. Are we missing some settings?

A manual restart of the reverse proxy solves the problem. However, this is not a long-term solution.

Upvotes: 0

Views: 1027

Answers (1)

nbari
nbari

Reputation: 26985

Probably using Nginx resolver could help, from the docs:

Configures name servers used to resolve names of upstream servers into addresses, for example: resolver 127.0.0.1 [::1]:5353;

You could use it globally:

resolver 10.0.0.2 valid=300s;
resolver_timeout 10s;

location /foo {
    set $foo_backend_servers foo_backends.example.com;
    proxy_pass http://$foo_backend_servers;
 }

Or per location:

location /foo {
    proxy_pass http://foo_backends;
    resolver 10.0.0.2 valid=300s;
    resolver_timeout 10s;
}

Problem is to know what DNS server to use, from these links:

resolver 169.254.0.2; is used, just in case, the 169.254.0.0/16 IPv4 range belongs to the Link-local address, so better double check what DNS server to use.

Upvotes: 1

Related Questions