Enabling host header mapping for authoring and production

Laks has posted a very good summary on how to implement host header mapping for authoring and production in the newsgroup which I would like to share with all of you:

I had gone through some trouble in figuring out this need. With help from stefans notes and microsoft support, i have put this together…
hope it is helpful..

Taking CMS sites live through “Map Channels to Host Header names”

Typical testing of CMS websites in development environment is as follows:
http://localhost/www.abc.com/

Obviously this is not the way we can go live with. The production URL will have to be www.abc.com for the above scenario. Since the coding is done and tested for the first scenario, often when you take your site live, you will end up with a lot of broken urls etc.

This document is intended to simulate a test environment that will behave like your actual production and authoring sites.

Of the several ways that can be used to take a CMS site live, this is just one method.

Under the assumption that the production architecture is such that both the Production and Authoring will share the same database.

Have two web servers.

WS1 = Read Only  ( Production )
WS2 = Read / Write (Authoring )
DB1 = CMS_DB

Both the web servers point to the same database on DB1 server. The Database can be set using the DCA of Microsoft Content Management Server.

SCA setting can be done through any site.  Set a value of Yes to “Map Channels to Host Header names”.

Open a case with Microsoft to get hot fix for id 824597. This hot fix can be obtained only through opening a case with Microsoft.

(824597 – Absolute URL is returned when you use the channel.URL method of the API and Host headers are enabled)

Install the hot fix on the Authoring Server. Also download the ISAPI_Rewrite Lite (freeware) from http://www.isapirewrite.com . This can be downloaded for free. Install ISAPIrewrite on the authoring server.

Under the assumption that your channel structure is as follows
– Channels
   o    www.abc.com
   o    www.def.com
   o    www.abc.co.uk

Lets assume based on the structure above, the sites need to be navigated as http://www.abc.com by end users and as http://authoring.abc.com by publishers.

Make the following entry on your hosts file on the production(WS1) web server. Hosts file is found on C:\Windows\System32\drivers\etc\hosts.
Open the file in notepad and make the following entries towards the end of the file.

172.21.231.85 www.abc.com
172.21.231.85 www.def.com
172.21.231.85 www.ab.co.uk

The initial portion is the IP address of the production(WS1) server. You can get the IP of the server by typing “ipconfig” on the command prompt of the machine or by pinging the server by its name.

Perform an “iisreset”.
You should now be able to test the production server for the different sites by typing the URLs typed in the hosts file. Any link generated by CMS will work. Links that have been hard coded will fail. Typically, it is an easy fix if the urls have not been hard coded and were being referenced from web.config file.

The production url works fine now. How will the authoring work. Map channels has been enabled, but that does not mean the publishers can access the same site to do publishing. You have to be able to distinguish between Authoring site and Production site.

Let us set up the authoring site.
As a result of installing ISAPIrewrite, httpd.ini file is created in the folder InstallDirectory\Helicon\ISAPI_Rewrite\httpd.ini

Open the file in notepad and add the following lines of code towards the end of the file
RewriteCond  Host:  authoring\.abc\.com
RewriteHeader Host: .* www\.abc\.com

RewriteCond  Host:  authoring\.def\.com
RewriteHeader Host: .* www\.def\.com

RewriteCond  Host:  authoring\.abc\.co\.uk
RewriteHeader Host: .* www\.abc\.co\.uk

On the authoring server, edit the hosts file located in C:\Windows\System32\drivers\etc\hosts make the following entries

172.21.231.64 authoring.abc.com
172.21.231.65 authoring.def.com
172.21.231.66 authoring.abc.co.uk

Perform an “iisreset”.
Now your authoring will behave in the same way as the production with the exception that you will use authoring in place of www in the prefix.

For the actual production server the hosts file is not modified.
Instead the IP in DNS points to the actual url name. Ex. www.abc.com

Additional notes:

In addition to the hints from Laks above you need to take care of some other things when you are planning to implement host header mapping with authoring and production server or when you are planning to place the production or authoring server behind a publishing proxy server. In these situations the MCMS server will most likely be hit with a different host name when the request is forwarded from the proxy server than the host name the user entered in the browser (e.g. the netbios name rather than the DNS name or a DNS name that meets the domain name structure of the internal network.

In this situation you need to disable the <base> tag rendered by the RobotMetaTag control by either removing the RobotMetaTag control or by adding the following statement to the Page_Load event of each template if you would like to preserve the other features of this control:

   RobotMetaTag1.RenderBaseHref = false;

Be aware that you need to code all references to local resources like stylesheets or javascript files using absolut URLs (starting with a “/”) in the template file. Relative references will no longer work when the base tag is not included.

If the MCMS server machine is published through a proxy server then you need also ensure that the hotfix mentioned above is also installed on the production server machines and not only on the authoring machine for the same reason.

824597 – Absolute URL is returned when you use the channel.URL method of the API and Host headers are enabled

12 Comments


  1. where is was 1/2 year ago ;-(

    we had so manny problems with that…

    Reply

  2. when I edit a site and then click on "Switch to live site" on the WBC, it trys and goes to the http://www.abc.com, not the authoring.abc.com.

    Any Ideas ?

    Thanks

    Reply

  3. This can happen if you did not install the latest Service Pack. SP2 contains a fix for this.

    Reply

  4. Hi,

    I have a problem in Deploying authoring and publishing mode with host header mapping,I am doing Authoring on Port 81 where as the Publishing on 80, and I have mapped my host header by the hosts file,now when I try to open the Authoring Site it gives me an Error saying Resource not Found where as the Publishing works, it looks one IIS cannot have Authoring and Publishing configured on different ports if No then please tell me how to do it.

    Thanks

    Reply

  5. Hi Ankit,

    you assumption is not correct. Authoring and Publishing can be on the same server with different ports. I’m using this every day.

    So your error is somewhere else.

    Cheers,

    Stefan

    Reply

  6. Hi Stefan,

    Thanks for the prompt reply, it looks What I am doing to configure the Authoring and Publishing is wrong, can you suggest me a Document or a Blog which explains about how to configure both the Sites on same IIS & Different Ports with Host Header Mapping , I am sure it will help me out

    Thanks in Advance

    Reply

  7. Hi,

    not sure if there is some documentation out.

    Which service pack level are you on? There is an old bug which has been fixed long ago which caused problems with host header mapping. Should be included in SP2.

    Cheers,

    Stefan

    Reply

  8. Hi,

    I am using SP2 and when I try to browse the Site I get the following Error:

    The resource cannot be found.

    Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed

    As the Site looks for
    http://sitename:81/EN/ where as the same site works for port 80
    http://sitename/EN/

    Earlier I had issue with the NTLM but I was able to resolve it by reading NTLM Document of Microsoft but now this thing is blocking the site to be used from Port 81.

    Reply

  9. Hi Ankit,

    then please open a support case for this to get this analyzed.

    Cheers,

    Stefan

    Reply

  10. Hi,

    how do I do that to get it analyzed?

    Reply

  11. Thank you once again Stefan 🙂

    Reply

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.