Sitecore Reverse Proxy Gotchas

Post Date: September 01, 2014

Sitecore is a content management system that tracks web analytics data about users visiting the sites powered by Sitecore. This tracking system uses the IP address of the site visitor to determine useful information such as what country the user is in. This type of tracking can also be used to determine what type of content to show a site visitor and gives the power to content managers to personalize a website experience based on the data Sitecore is capturing about a site visitor. Now you have to admit, that is pretty cool.

Since this functionality is a part of the core product, some developers may assume that this functionality will work the same as it does on local development machines or test servers. However, operating from that assumption in a real production environment can cause significant frustrations if an understanding of the target production environment is not understood by the developers of the Sitecore solution. One area that can be pinned as a gotcha is working with an environment that has a reverse proxy server. This post will not go into the specifics of what a reverse proxy is or why an environment may use one.

Below is a diagram illustrating what a typical environment setup would like look without the use of reverse proxy.


Below is a diagram illustrated what an environment may look like with a reverse proxy server.


When Sitecore detects that a user is visiting the website, it will capture the IP address of the visiting user. When the site user hits the web server directly without a reverse proxy in the middle, Sitecore can get the IP address naturally. However, when there is a reverse proxy in between the webserver and the site visitor, it is very possible that the IP address the webserver will get will be the IP address of the reverse proxy server instead of the IP address of the site visitor. The reverse proxy is accepting the request from the site visitor and then routing those requests to web the server that is hosting the Sitecore solution. When this happens, the reverse proxy makes the request as the proxy instead of as the site visitor. Now there are a ton of reverse proxy solutions and they all have different options and configurations that might be used to fix this problem. A common practice is to configure the reverse proxy server to pass the original IP address to the webserver through an HTTP header. Some common HTTP header names that are used are “X-Forwarded-For” and “X-Real-IP”. Once this update has been made, there is a configuration setting in the Sitecore files to update so that Sitecore knows where to look for the original IP address. It is located in the “Sitecore.Analytics.config” and is called “Analytics.ForwardedRequestHttpHeader”.

Benjamin Vidal

I am a Sitecore ninja. I stand strong in the face of adversity. ACTIVATE ME!