none
Host Multiple Sites from ONE Azure IIS Server

    Question

  • I am trying to host three websites from a single IIS server and am having some trouble getting them to work. I have all three sites created in IIS, but can only get one of them to open in a web browser. I have searched the site for some help, but everything is telling me to set a host header record and I can't seem to find an option for hostHeader in the GUI.

    I checked this resource CheckHere, but it doesn't really tell me what I need to know. Looking at my setup it is all correct, but only one of the sites will open.

    I have never worked with IIS before so I'm pretty confused on the setup.

    Any help would be appreciated.

    Thursday, September 13, 2012 8:10 PM

Answers

  • I saw your post over the last few days trying to solve this myself. I came up with a solution (so, I thought I should share it). I saw posts about using CNAMES, but it still didn't truly address a proper domain name routing, so I kept working on it.

    As a web developer, I always thought you had to have a dedicated IP address on the server for each website because you had to have it for the domain name routing. I truly thought this was the only way. But, I was wrong, and learned something valuable today.. especially regarding hosting multiple sites in IIS on an Azure Virtual Machine (this workaround does not work for an Azure web role.. there are other posts about that on here already).

    Multiple sites can share the same IP and IIS can route the traffic using your domain names only. When you right click and add each site in IIS, you select the only IP address that is in there (which is your private virtual machine IP), port 80, and then enter the website domain name... i.e. mysite.com (called the host name). It is a good practice to also add a second entry for the site exactly like the first one (private IP, port 80), but this time include "www" ... i.e. www.mysite.com. Then, you can go to your DNS host (this can be register.com or godaddy, or a DNS hosting company) and create an A record and point it to your public IP address for your virtual machine. You can add as many sites as you want to your virtual server using this method. (yes, as wierd as it sounds, you use the same IP address in the DNS records for every site you host on this server).

    Microsoft has said that your main public endpoint (your public IP address) will not change for the virtual machine unless you delete it at some point. So, if you ever do, and restore it, you'd need to put the new IP address in the DNS routings for any of the sites you are hosting. If not, they would stop working.

    As a side note... there is one other way you can host multiple sites. i.e. you can also leave off the host names, and assign different ports to each site and then get to them this way yourvirtualmachine.cloudapp.net:1001 (where 1001 is the port). If you do this, make sure you create endpoints for each port you want to use, and open them in windows firewall. I realized today this is useful if you really want to keep a domain completely private (an admin area, etc) and don't want it running on port 80 which is the standard port for http/internet sites. The reason you can't use this for routing domain names to multiple sites on your server? Nobody will let you create a DNS record with a port included (they all only allow the IP addresses).

    Hope this helps anybody out there who wants to host multiple sites, and wants to use normal professional domain routings (vs. using yoursite.cloudapp.net). Hopefully at some point Microsoft will setup a DNS system for Azure (and an email server you could use for your virtual machines) but until then, we'll all have to do these workarounds.

    Sunday, September 16, 2012 6:47 AM
  • Hi IMCOTech,

    What is the OS of your VM?  Can you look at below links and let me know if you are still unable to configure host headers?

    http://technet.microsoft.com/en-us/library/cc753195(WS.10).aspx

    http://weblogs.asp.net/owscott/archive/2011/02/12/setting-host-headers-for-ssl-sites-in-iis-week-7-of-52.aspx

    Alternatively, you can configure different ports for your websites and open the endpoints associated with those ports to ensure all the sites are working fine.

    For example, you can assign port 80 to first site and 81,82 to other two sites and ensure you open external endpoints for these ports via Endpoints section of the VM. The resource you referred is related to PaaS and not related to "Windows Azure Virtual Machines" feature.

    Thanks,

    Hari

    Friday, September 14, 2012 10:07 PM
    Moderator

All replies

  • Hi IMCOTech,

    What is the OS of your VM?  Can you look at below links and let me know if you are still unable to configure host headers?

    http://technet.microsoft.com/en-us/library/cc753195(WS.10).aspx

    http://weblogs.asp.net/owscott/archive/2011/02/12/setting-host-headers-for-ssl-sites-in-iis-week-7-of-52.aspx

    Alternatively, you can configure different ports for your websites and open the endpoints associated with those ports to ensure all the sites are working fine.

    For example, you can assign port 80 to first site and 81,82 to other two sites and ensure you open external endpoints for these ports via Endpoints section of the VM. The resource you referred is related to PaaS and not related to "Windows Azure Virtual Machines" feature.

    Thanks,

    Hari

    Friday, September 14, 2012 10:07 PM
    Moderator
  • I saw your post over the last few days trying to solve this myself. I came up with a solution (so, I thought I should share it). I saw posts about using CNAMES, but it still didn't truly address a proper domain name routing, so I kept working on it.

    As a web developer, I always thought you had to have a dedicated IP address on the server for each website because you had to have it for the domain name routing. I truly thought this was the only way. But, I was wrong, and learned something valuable today.. especially regarding hosting multiple sites in IIS on an Azure Virtual Machine (this workaround does not work for an Azure web role.. there are other posts about that on here already).

    Multiple sites can share the same IP and IIS can route the traffic using your domain names only. When you right click and add each site in IIS, you select the only IP address that is in there (which is your private virtual machine IP), port 80, and then enter the website domain name... i.e. mysite.com (called the host name). It is a good practice to also add a second entry for the site exactly like the first one (private IP, port 80), but this time include "www" ... i.e. www.mysite.com. Then, you can go to your DNS host (this can be register.com or godaddy, or a DNS hosting company) and create an A record and point it to your public IP address for your virtual machine. You can add as many sites as you want to your virtual server using this method. (yes, as wierd as it sounds, you use the same IP address in the DNS records for every site you host on this server).

    Microsoft has said that your main public endpoint (your public IP address) will not change for the virtual machine unless you delete it at some point. So, if you ever do, and restore it, you'd need to put the new IP address in the DNS routings for any of the sites you are hosting. If not, they would stop working.

    As a side note... there is one other way you can host multiple sites. i.e. you can also leave off the host names, and assign different ports to each site and then get to them this way yourvirtualmachine.cloudapp.net:1001 (where 1001 is the port). If you do this, make sure you create endpoints for each port you want to use, and open them in windows firewall. I realized today this is useful if you really want to keep a domain completely private (an admin area, etc) and don't want it running on port 80 which is the standard port for http/internet sites. The reason you can't use this for routing domain names to multiple sites on your server? Nobody will let you create a DNS record with a port included (they all only allow the IP addresses).

    Hope this helps anybody out there who wants to host multiple sites, and wants to use normal professional domain routings (vs. using yoursite.cloudapp.net). Hopefully at some point Microsoft will setup a DNS system for Azure (and an email server you could use for your virtual machines) but until then, we'll all have to do these workarounds.

    Sunday, September 16, 2012 6:47 AM
  • Thank you Hari and Jeffrey, I was able to make this work by assigning different ports to each site.

    Jeffrey, your post was most helpful, all information contained within one post made it easy to find the step I had missed the first time around.

    Thanks again!

    Wednesday, September 19, 2012 3:33 PM
  • I have 6 websites which i need to host on azure VM win2008r2, but facing issue to set wesite on iis server. By assigning different port, i can access sites but setting port to 80 results in error.

    Can you guide me step by step how to bind and set CNAME record in domain config.

    Tuesday, January 28, 2014 2:25 PM
  • I have created 2nd site with port 81 opened end point , I have given custom domain to default site by dns myapp.cloudapp.net it is working fine. How to give custom domain to 2nd site with port 81 ?
    Monday, April 7, 2014 6:59 AM
  • Thanks Buddy... it works

    god bless u

    Friday, December 18, 2015 8:58 AM