What are the pros/cons of using a resolver per location, I found this configuration on a server but my guess is that it not "re-resolving" since the proxy_pass
is not also using a variable
location /foo {
proxy_pass http://foo_backends;
resolver 10.0.0.2 valid=300s;
resolver_timeout 10s;
}
location /bar {
proxy_pass http://bar_backends;
resolver 10.0.0.2 valid=300s;
resolver_timeout 10s;
}
From the docs:
When you use a variable to specify the domain name in the proxy_pass directive, NGINX re‑resolves the domain name when its TTL expires.
Therefore if I am right the previous configuration could be rewritten like this:
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;
}
location /bar {
set $bar_backend_servers bar_backends.example.com;
proxy_pass http://$bar_backend_servers;
}
Is this correct or there is some trick when using location per location? could it be that by using a resolver per location there is no need to create a variable and pass it to proxy_pass
?
0 Answers