Use a variable for the domain name; this way allows you to customize how frequently NGINX recursively resolves the domain name.
resolver 10.0.0.4 valid=20s;
server {
location / {
set $backend_servers backend.seimaxim.com;
proxy_pass http://$backend_servers:8080;
}
}
When a variable is used in the proxy_pass directive to define the domain name, NGINX reresolves the domain name when the TTL expires. To explicitly define the name server, the resolver directive must be used.
By providing the valid argument in the resolver directive, NGINX is told to ignore the TTL and instead reresolve names at a set frequency. NGINX will reresolve names every 20 seconds in the example above.