doh_port
The doh_port directive sets the port for the upstream DNS server in the DNS-over-HTTPS module.
Description
The doh_port directive is used in NGINX configurations to specify the port number of the upstream DNS server that handles DNS-over-HTTPS (DoH) requests. It is particularly useful when the default DNS server port (53) is not in use or when the DNS server is running on a different port. This directive must be placed within a valid location block where the DoH functionality is enabled by using the doh directive.
When the doh_port directive is specified, it informs the NGINX module to direct DNS queries through the specified port using both TCP and UDP connections. Failure to properly set the port may result in unsuccessful query handling, with NGINX unable to reach the intended DNS server. The typical usage is in conjunction with the doh_address directive, which specifies the address of the DNS server, ensuring that both configurations are set correctly for seamless DNS handling.
The module will read and apply the value set in doh_port when a DNS query is initiated from a client request. Proper port configuration is critical, especially when working with multiple services that may operate on non-standard ports, preventing conflicts with other network operations.
Config Example
location /dns-query {
doh;
doh_port 5353;
}Ensure that the specified port is open and reachable by the NGINX server to avoid connection issues.
Remember that the default port is 53; configuration needs to specifically change it if using a custom port.
In case of using a firewall, confirm that it allows traffic on the specified port.