Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what is the difference in resolver valid time and resolver_timeout in nginx

Tags:

nginx

I have this nginx configuration entry.

http {
  resolver 172.17.42.1 valid=600s;
  resolver_timeout 60s;

In this configuration there 2 two different timeouts. The nginx documentation does not make it clear to me what is the difference between valid and resolver_timeout.

Can someone explain in detail?

like image 835
Vad1mo Avatar asked Dec 14 '22 16:12

Vad1mo


1 Answers

resolve_timeout sets how long NGINX will wait for answer from resolver (DNS).

valid flag means how long NGINX will consider answer from resolver as valid and will not ask resolver for that period.

In your example, let's say NGINX want to resolve example.com. It will ask resolver (172.17.42.1) and if resolver doesn't answer within 60 seconds NGINX will fail this request (and probably show you 500 error). Let's say resolver successfully answered, then NGINX will remember that answer for 10 minutes. If NGINX needs to resolve example.com within that time, then it will use previous answer instead of asking resolver again.

like image 82
Alexey Ten Avatar answered May 18 '23 17:05

Alexey Ten