DnsServer: fixed issue in DNS-over-HTTP private IP check causing 403 with reverse proxy.

This commit is contained in:
Shreyas Zare
2023-02-26 17:26:55 +05:30
parent 7c82ed7907
commit c1f287528b

View File

@@ -768,13 +768,19 @@ namespace DnsServerCore.Dns
return;
}
if (!request.IsHttps && !NetUtilities.IsPrivateIP(remoteEP.Address))
if (!request.IsHttps)
{
//intentionally blocking public IP addresses from using DNS-over-HTTP (without TLS)
//this feature is intended to be used with an SSL terminated reverse proxy like nginx on private network
response.StatusCode = 403;
await response.WriteAsync("DNS-over-HTTPS (DoH) queries are supported only on HTTPS.");
return;
//get the actual connection remote EP
IPEndPoint connectionEp = context.GetRemoteEndPoint(true);
if (!NetUtilities.IsPrivateIP(connectionEp.Address))
{
//intentionally blocking public IP addresses from using DNS-over-HTTP (without TLS)
//this feature is intended to be used with an SSL terminated reverse proxy like nginx on private network
response.StatusCode = 403;
await response.WriteAsync("DNS-over-HTTPS (DoH) queries are supported only on HTTPS.");
return;
}
}
switch (request.Method)