added X-Real-IP support to get client IP from reverse proxy.

This commit is contained in:
Shreyas Zare
2019-03-03 19:29:21 +05:30
parent 1cedea6391
commit 82f8f22e4c

View File

@@ -536,8 +536,16 @@ namespace DnsServerCore
return;
}
string xRealIp = request.Headers["X-Real-IP"];
string xForwardedFor = request.Headers["X-Forwarded-For"];
if (!string.IsNullOrEmpty(xForwardedFor))
if (!string.IsNullOrEmpty(xRealIp))
{
//get the real IP address of the requesting client from X-Real-IP header set in nginx proxy_pass block
remoteEP = new IPEndPoint(IPAddress.Parse(xRealIp), 0);
}
else if (!string.IsNullOrEmpty(xForwardedFor))
{
//get the real IP address of the requesting client from X-Forwarded-For header set in nginx proxy_pass block
string[] xForwardedForParts = xForwardedFor.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);