doh_timeout

Sets the timeout for DNS-over-HTTPS requests in milliseconds.

Syntaxdoh_timeout time;
Default5000
Contextlocation
Arguments1

Description

The doh_timeout directive in NGINX is used to specify the maximum time, in milliseconds, that the server should wait for a response from an upstream DNS server when processing DNS-over-HTTPS (DOH) requests. This directive plays a crucial role in defining the responsiveness of the DOH service, as it relates to how long the server is willing to wait for a DNS answer before timing out.

Typically set within a location block, the doh_timeout directive takes a single argument that denotes the timeout period. If the response from the upstream DNS server exceeds this specified duration, NGINX will terminate the request, allowing it to handle other requests without being stalled by slow DNS responses. The timeout can be adjusted based on the specific needs of the application and the expected performance of the upstream DNS server.

By default, if not specified, the timeout is set to 5000 milliseconds (5 seconds). This allows for some flexibility; administrators can reduce the value for quicker failovers or increase it when interfacing with slower DNS servers. However, setting the timeout too high may lead to inefficient request handling, especially under high load conditions.

Config Example

location /dns-query { 
    doh;
    doh_timeout 2000;  
}

A value set too low may lead to frequent timeouts if the upstream DNS server responds slowly.

Ensure the timeout value is specified in milliseconds; confusion with seconds can lead to unexpected behaviors.

It's crucial to set this directive in a proper location block; otherwise, it may not take effect.

← Back to all directives