cgi_rdns

The `cgi_rdns` directive configures the behavior of reverse DNS lookups for CGI scripts in NGINX.

Syntaxcgi_rdns on | off | double | required;
Defaultoff
Contextserver, location
Arguments1-2

Description

The cgi_rdns directive in NGINX is used to control reverse DNS lookups for CGI scripts executed through this module. The directive can be set to one of four values: OFF (0), ON (1), DOUBLE (2), or REQUIRED (4). Setting it to OFF disables reverse DNS lookups, which can speed up processing but may affect logging capabilities. Setting it to ON will enable reverse DNS lookups only once per IP address, while DOUBLE causes the system to perform reverse lookups for both the client IP and the local server IP. The REQUIRED option mandates reverse lookups for every request, ensuring that the address is fully resolved before processing begins, which could lead to added latency in requests depending on the DNS response time.

This directive is applicable at the server and location contexts, allowing for granular control depending on the specific needs of different CGI scripts or web applications. The behavior is particularly relevant in environments where accurate logging of client IP addresses is required, as reverse DNS can provide human-readable hostnames instead of raw IP addresses. However, users should be cautious about the potential performance impacts, especially in high-traffic environments, as waiting for DNS resolution can introduce latency.

Config Example

location /cgi-bin/ {
    cgi_rdns on;
    cgi_pass /path/to/cgi-script;
}

Enabling reverse DNS lookups can increase latency for each request, especially if DNS responses are slow.

Setting cgi_rdns to REQUIRED can lead to timeouts if the DNS server is unreachable, potentially affecting your service's availability.

Misconfigured DNS records can lead to unexpected behavior in CGI script execution or logging.

← Back to all directives