Load balancer IP header can not be parsed if port number is provided


Description

The Azure App Gateway includes a port number when relaying traffic. This means that the load balancer returns the X-Forwarded-For header field both with IP-address and IP:port value that is not not parsed properly. For example, most load balancers return the X-Forwarded-For with an IP, like "127.0.0.1", "192.168.0.0". But the Azure App Gateway returns "127.0.0.1:45712", "192.168.0.0:28336" and so on. This breaks the header processing and may lead to the failure of GeoIP resolution for an Azure Sitecore implementation. The following message might appear in the Sitecore logs:
Cannot parse a valid IP address from X-Forwarded-For header

Solution

To resolve the issue, download and install the patch available on this page:
https://github.com/SitecoreSupport/Sitecore.Support.132442/releases.
To get a solution for other XP releases, contact Sitecore Support.