We routinely bypass Cloudflare when we access our admin site to fulfil orders. By default when customers access NOP though Cloudflare the customer IP gets replaced by the Cloudflare Proxy IP. I have modified the code below to detect if the visitor came via Cloudflare and replace the IP with the correct one or to use the normal method.
Enjoy.
Nop.Core.WebHelper
/// <summary>
/// Get context IP address
/// </summary>
/// <returns>URL referrer</returns>
public virtual string GetCurrentIpAddress()
{
if (_httpContext.Request.Headers["CF-Connecting-IP"] != null &&
_httpContext.Request.Headers["CF-Connecting-IP"].Length > 1)
{
return _httpContext.Request.Headers["CF-Connecting-IP"];
}
else
{
return _httpContext.Request.UserHostAddress;
}[code]
return string.Empty;
}
[/code]