HTTP upstream directives

resolver directive (upstream (OSS 1.27.3+))

Context: upstream (OSS 1.27.3+). Configures trusted runtime DNS; by default caches answers for their TTL. valid overrides cache validity. status_zone is commercial. The upstream-context form was commercial before OSS 1.27.3.

Formal Syntax & Structure

nginx syntaxnginx
resolver address ... [valid=time] [ipv4=on|off] [ipv6=on|off] [status_zone=zone];

Parameters & Attributes

NameTypeDescription
addressDNS server address with optional port (repeatable)Use an approved resolver; default port 53.
validvalid=durationOverride response TTL for cached answers.
ipv4ipv4=on|offSelect IPv4 queries; off supported since 1.23.1.
ipv6ipv6=on|offSelect IPv6 queries.
status_zonestatus_zone=nameCommercial DNS metrics zone.

Working Example

Example Snippetnginx
resolver 127.0.0.1:15353 valid=15s;
Nginx Reference