1

I have a server that I want to host multiple web sites on using host headers. I know how to set IIS up but I am unsure how to set up the domain name. I have a domain name (ex. mydomain.com) that I want to redirect to an IP address (12.138.XXX.XXX).

Do I create an "A" record to redirect the domain to the IP address and a CNAME record to hold the host header value? I can get the domain name to redirect but IIS doesn't direct it to the correct web site.

masegaloeh
  • 17,978
  • 9
  • 56
  • 104
Brian Kalski
  • 123
  • 1
  • 4

3 Answers3

4

Adding onto what the others have said and clarifying it. Yes you're getting mixed up between DNS and Host header. The DNS system is just for resolving names. This is how it works.

Basically in the browser you'll enter in a URL like:

http://www.example.com

In DNS, an A record for www.example.com resolves to 93.184.216.34.

Lets say that 93.184.216.34 is your very own web server running IIS.

It's the browser that sends the host header. The browser would send a request to the web server which will look something like:

GET / HTTP/1.1    
Host: www.example.com  

The web server which may be hosting multiple websites sees www.example.com and serves up that website.

If you want to add another website, you'd configure another website in IIS and tell it what host it's for, and add another website domain to DNS which also points to your webserver at: 93.184.216.34. i.e. just add another DNS A record entry for the domain and you're set.

I hope this makes sense.

hookenz
  • 14,132
  • 22
  • 86
  • 142
2

Whatever URL has been navigated to is what will decide the Host header value. Ie, DNS does not actually affect this.

On the DNS side of things you will simply want to ensure that the relevant names resolve to the correct IP addresses (A records will be fine for this).

On the web server side of things you will want to map the relevant host names to go to the appropriate sites (Bindings in the IIS Manager).

Håkan Lindqvist
  • 33,741
  • 5
  • 65
  • 90
  • So if my domain name is example.com IIS will see the host header of example.com even if I redirect to an ip address? – Brian Kalski Mar 22 '15 at 17:07
  • @BrianKalski What exactly do you mean by "redirect to an IP address"? If you mean an HTTP redirect, that will cause the URL to change and thus the Host header will change. – Håkan Lindqvist Mar 22 '15 at 17:10
  • Basically what I am trying to accomplish is to direct a domain to an ip address and from there redirect the request to a web site using host headers in IIS. I have multiple web sites hosted on that ip address. I'm just not sure how to set the domain name up. – Brian Kalski Mar 22 '15 at 17:55
  • @BrianKalski There are only the two steps listed in my answer; add the address record in DNS, map the host name to the right site in the web server configuration. – Håkan Lindqvist Mar 22 '15 at 18:20
1

You're getting things mixed up. As Håkan Lindqvist stated in his answer, all you need to do is to set up the A record in your DNS zone for the name of the site (somesite.yourdomain.com) and set up matching host headers in the IIS bindings of the appropriate website on your server. There's no "redirection" taking place, there's no need for a CNAME record. All you need to do is to create the A record with the proper name and add the matching host headers to the bindings of the website.

A record = somesite.yourdomain.com = 1.1.1.1

IIS host headers = somesite.yourdomain.com

joeqwerty
  • 108,377
  • 6
  • 80
  • 171