Request Host Header, Sitecore Site hostName & Reverse Proxy

This is very basic but very important while doing the sitecore deployments on the production environment that is defining the sitecore sites definition and resolving incoming requests, on CD server, with the correct site definition.

In my experience with Sitecore, I have faced this problem twice that incoming requests, on CD server, do not map to the desire site that is defined in sitecore sites config. Each time the reason for this behavior was same but with different scenarios.

Scenario 1 – Reverse Proxy

Right on the time when everything was ready to go live, client requested to point domain to the reverse proxy IP so I did it. I also configured Load Balancer to accept traffic only from reverse proxy IP and client configured reverse proxy for the Load Balancer. After configuring everything for reverse proxy, I hit the url and content started to render but I noticed that links generated on website were not as defined in site definition and link manager. After lots of debugging I diagnosed that the host header of the requests coming to CD servers don’t have website address which could map with hostName defined in sites config.

For the resolution of this problem, I asked client to set host header as website domain in proxy server’s request while forwarding request to load balancer.

Scenario 2 – Frontend Linux Server

This time client was a British bank and their environment was much secured as it should be. Linux server was exposed publicly and it was redirecting incoming request to the IIS of windows server where sitecore website was deployed. Again same problem occurred requests were not mapping to the sites defined in sitecore config. I checked the host header for incoming request and found the issue that request had the Linux server name in the host header instead of the website domain name.

As a solution client made some updates on their server which fix the problem. I really don’t know what they did on the Linux server as we’re not allowed to touch them.

What could happen if site definition doesn’t resolve from incoming requests?

  • Link manager will not generate the links as what defined in configuration.
  • Incorrect analytics will be gathered.
  • DMS will not work properly.
  • Sitecore caching might not work.

Check Host Header on CD Serer

Following code could be placed in any rendering layout to check the request Host value receiving at CD server.

Page.Context.Request.Headers.GetValues(“Host”)

Leave a Reply

Your email address will not be published. Required fields are marked *

rfwbs-slide