Wildcard host header ?

Does IIS support wildcard host header ? Can I capture and redirect *.mydomain.com to one web site ? 
The answer is Yes/No. Yes, because you are able to redirect *.mydomain.com to one web site. No, because the magic is in DNS and not IIS.

Here's how you do it:
At IIS MMC, configure a web site with NO host header, then assign an IP address to the site. (if you have one IP address in the box, then you can skip this). With this, the web site will bound to the specific IP and will listen to all HTTP requests send to the IP, and you are done :) 

Next step is to make sure your name resolution works for the wildcard query and reply with the correct IP address. If you using Microsoft DNS service, it won't allow you to create a '*' A record (assuming you already created the domain zone in DNS MMC), you need to do the following:

a) Navigate to %windir%\system32\dns\
b) Find the zone file. E.g. mydomain.com.dns, open it with Notepad
c) Add an entry. E.g.
    *     A    IP.IP.IP.IP
d) Save the zone data file
e) Reload the zone data in DNS MMC.

Take note that by doing this, all * will response to the IP that you configured earlier. E.g. abc.mydomain.com, www.mydomain.com, K2k.mydomain.com and etc.

To verify that it is working, try ping utility
Ping (insert anything here).mydomain.com .. and you should get replies from IP.IP.IP.IP

Then try browsing,
http://(insert anything here).mydomain.com/, you should get the same web page that you have configured.

Published Tue, Mar 22 2005 12:07 by bernard
Filed under: ,

Comments

# bernard said on 29 April, 2005 09:32 AM
IIS 6 doesn't allow you to configure a website with no host headers.
Is there anything else I can do?

Thanks
# bernard said on 03 May, 2005 01:32 AM
This also assumes that you have 1 IP per website. You still can't do *.domain.com in IIS, unless you give each site it's own IP. I have roughly 400 sites shared on 1 IP, and would love to do this, however I don't want to have to apply for 400 more IP addresses, nor do the DNS changes ;)
# bernard said on 03 May, 2005 10:13 AM
Hi Rehan,

IIS 6 supports host header, refer
HOW TO: Use Host Header Names to Configure Multiple Web Sites in Internet Information Services 6.0
http://support.microsoft.com/?id=324287
# bernard said on 03 May, 2005 10:14 AM
Hi Matt,

For each wildcard host header *.domain.com you need one IP, and you will have ONE site. Since you have 400 sites with different domain URL, you will need 400 IPs if you want to utilized this feature.

You can use host header to host 400 sites with 1 IP. But for *.domain.com to work for that, we need to skip the host header and listen on the IP only. Hence, you are referring 400 *.domain.com sites and you need 400 IPs in a way. One way to skip the IP is, configure *.domain.com for that 400 domains, then when request hit the default page of the ONE site, using scripting to dynamic parse the URI then redirect to a proper site or virtual directory.
# TrackBack said on 24 May, 2005 11:41 PM
# TrackBack said on 25 May, 2005 12:56 AM
# bernard said on 09 August, 2005 03:31 AM
I've taken all the steps you've listed and I still can't get wildcards to work. I've already got a blank A record (same as parent folder) pointing to one IP and a 'www' A record pointing to another IP. I need anything else to point to a different IP. Will the wildcard record only work if it's the only A record?

ie - mydomain.com => IP1
www.mydomain.com => IP2
*.mydomain.com => IP3
# bernard said on 09 August, 2005 07:35 PM
Interesting setup you have there. Not sure if ie / www will get resolved to IP3. So now, when you ping ie or www, does it resolve to IP1/IP2 or IP3.

What is not working? if you ping super.mydomain.com - it should returns IP3 and the IP3 website should bind to IP address without any host header value.
# bernard said on 10 August, 2005 02:18 AM
This is what's listed in the mydomain.com.dns file on our DNS server:

--------------------------------
;
; Zone records
;

@ A [IP1]
@ MX 10 maildomain.mydomain.com.
www A [IP2]
* IN [IP3]
----------------------------------

On our IIS server there's an entry for IP1 with no host header, an entry for IP2 with a www.mydomain.com host header and an entry for IP3 with no host header.

When I ping mydomain.com, it returns IP1. When I ping www.mydomain.com it returns IP2. When I ping [anything].mydomain.com it returns 'Unknown host [anything].mydomain.com'
# bernard said on 10 August, 2005 10:49 AM
Hi Donovan,

Thanks for the clarification, You are correct, it's a 'A' record not IN, I have updated the post, my apologize on the typo :( it should be:
* A IP.IP.IP.IP

Thank you.
# bernard said on 12 August, 2005 02:28 AM
Thanks Bernard.

It's working for me now. I had actually already tried changing 'IN' to 'A' previously and it still didn't work. I'm not sure what I did differently this time, but I think it had to do with modifying the entry on BOTH DNS servers. I thought it would automatically import from DNS1 to DNS2 but I had to change the physical .dns file on both servers.

Thanks for your help.
# bernard said on 12 August, 2005 02:43 PM
No problem. When I tested it I didn't try on zone transfer to secondary DNS servers. Have you try transfer from master, any event log? I think it should transfer without any problem.
# Nicholas said on 24 October, 2006 07:55 PM
Shame, I have a customer insisting on shared IIS hosting, who also wants wildcard subdomains for his site, it's simply not possible without giving their site a static ip, in apache this is easy to do an a shared ip, you simply tell apache the ServerAlias *.domain.tld and it will recognise it regarless of the fact that the ip address is being used by other host headers for different sites.
# qbernard said on 25 October, 2006 12:00 AM

Well, feedback already given to product team.

News

Search

Go

This Blog

Tags

Archives

IIS Sites

MVPs - MVPs

IIS Related

Syndication