Using Nginx Open source v1.20.2
I am defining resolver directive in http block, without "valid" parameter. For one specific location block, I want to override this resolver definition and set valid = 300s parameter.
When trying to define resolver directive in both http and location block, the configuration from http block seems to always take effect. The validity set to 300 seconds within that specific location block is ignored. DNS records of foo.com are not being cached for 300 seconds.
A dummy nginx config for demonstration:
http {
resolver 127.0.0.1;
server {
server_name something.com;
location {
resolver 127.0.0.1 valid=300s; # here dns is not cached for 300 seconds
set $backend foo.com
proxy_pass http://$backend
}
}
}