What does the Resolver param in nginx do? What does the Resolver param in nginx do? nginx nginx

What does the Resolver param in nginx do?


The nginx resolver directive is required because the system resolver blocks. Nginx is a multiplexing server (many connections in one OS process), so each call of system resolver will stop processing all connections till the resolver answer is received. That's why Nginx implemented its own internal non-blocking resolver.

If your config file has static DNS names (not generated), and you do not care about track IP changes without nginx reload, you don't need nginx's resolver. In this case all DNS names will be resolved on startup.

Nginx's resolver should be used, if you want to resolve domain name in runtime without nginx reload.


Nginx resolver directive is critical to any AWS environment that relies on ELB and proxy_pass. Here is the post that I wrote recently describing problem and solutions to the static DNS caching by opensource nginx:

Nginx resolver explained and how to deal with changing IPs

Basically it will boil down to following config for simple case:

server {  listen        80;  server_name   example.com;  location / {    resolver 172.16.0.23;    set $upstream_endpoint http://service-999999.eu-west-2.elb.amazonaws.com;    proxy_pass $upstream_endpoint$request_uri;  }}