Wildcard Host Header Binding And Subdomains with IIS7

DNS, IIS Add comments

Like its predecessors, IIS7 does not support wildcard (catch-all) binding or wildcards for host names, see this discussion for the state of things and how the much requested feature didn’t make it into the II7 release version as it stands. So, if you try to add *.yourdomain.com as a host name in IIS 7 you will get this warning:

The specified host name is invalid. The valid characters are ...

There is only one “workaround” at the web server level and it requires a dedicated IP address for the particular site:

Set up a wildcard host record in DNS: right-click the zone yourdomain.com in DNS Manager>>New Host (A or AAAA)>>enter asterisk as wildcard and the dedicated IP address:

New Host for wildcard binding in DNS 

Then create you site in IIS without any host name:

image

This way DNS effectively takes care of the mapping of the URLs, throwing everything at the bound IP address which is pointing to your site. Here’s hoping that IIS will someday catch up with Apache and allow more flexible wildcard mapping of host names.

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

15 Responses to “Wildcard Host Header Binding And Subdomains with IIS7”

  1. Asteptals Says:

    Подскажите шооблончег под WordPress 2.6.2, чтобы был похож на ваш dirk.net.

    Заранее благодарю)

  2. DNS Server, IIS7 - Server Support Forum Says:

    [...] Hallo, Ich habe das selbe problem: Dirk.Net Blog Archive Wildcard Host Header Binding And Subdomains with IIS7 Alle Requests *.name.dyndns.com werden auf meinen Server weitergeleitet, wenn ich einer Site einen [...]

  3. Robert Rawlins Says:

    Thanks for writing this up, I’ve been looking into this today and find it so frustrating that despite what seems to be a large community backing for the feature M$ still haven’t got around to building something in.

    Cheers,

    Rob

  4. ps Says:

    But, you *can* do it at another level.

    Proceed as posted in the blog post, then use httpcfg.exe to restrict the binding to only the wildcard.

    It’s a question of *where* you bind it.

  5. Wildcard subdomains on localhost using IIS7 Says:

    [...] If you can ensure the site only receives traffic on one IP and you own/have dedicated access to the server, you can use DNS to “fake” out the behavior with a wildcard mapping and no host. There is a great post on this at http://dirk.net/2008/05/28/wildcard-host-header-binding-and-subdomains-with-iis7 [...]

  6. reza Says:

    hi
    thank you very much for your solution
    but , is there any security issue or traffic overhead problem with this method?
    if yes ? what should we do ?
    thanks again

  7. dirk Says:

    Hello reza, thanks for your comment.
    Apache has the wildcard bindings but IIS7 doesn’t, and there might be reasons for this, and the reasons might be those you stated, security and “uncertainty” for clients, search engines etc. Google and other search engines certainly won’t like this uncertainty and it will always better to create fixed DNS entries and host definitions if you can.

  8. Phillip H. Blanton Says:

    Not exactly. While not perfect, you can use a wildcard host header on one website on your IIS installation without the dedicated IP address.

    Refer to this image…

    http://content.screencast.com/users/pblanton/folders/Jing/media/12315692-57df-4413-ad47-1498daeca989/2011-03-01_0828.png

    I simply added ‘*’ as the hostname on the main website on my server. Since host headers must be unique, you can only do this on one website.

    With your DNS set up correctly, any request to an unmapped subdomain, will be mapped to the main site. Go ahead and try it. Browse to http://boogerflicker.phasepoint.net. No, I don’t have a DNS entry for boogerflicker.phasepoint.net. If you don’t believe me. make up a different subdomain to phasepoint.net and give it a shot.

  9. Patrick Says:

    You can flag the wildcard at your registrar, if they host your domains’s dns, and leave the binding open on IIS. You don’t need dns running on the server.

  10. Wildcard subdomains on localhost using IIS7 - Admins Goodies Says:

    [...] If you can ensure the site only receives traffic on one IP and you own/have dedicated access to the server, you can use DNS to “fake” out the behavior with a wildcard mapping and no host. There is a great post on this at http://dirk.net/2008/05/28/wildcard-host-header-binding-and-subdomains-with-iis7 [...]

  11. witsml Says:

    I’ve added a feature request here for wildcard hostheaders: https://connect.microsoft.com/WindowsServerFeedback/feedback/details/722874/wildcard-subdomain-hostheader-support-in-iis-7-5

  12. Rohith VR Says:

    its useful for me…thank you for you kind informations

  13. Roman Says:

    Where a can found DNS Manager ?? THX

  14. Lelala Says:

    hell, thanks a lot for pointing out to that issue – its really a PITA.
    (Especially if you do not wan’t to use MS-DNS stuff)
    When will it be available out of the box? :-(

  15. Wildcard subdomains on localhost using IIS7 - Just just easy answers Says:

    [...] If you can ensure the site only receives traffic on one IP and you own/have dedicated access to the server, you can use DNS to “fake” out the behavior with a wildcard mapping and no host. There is a great post on this at http://dirk.net/2008/05/28/wildcard-host-header-binding-and-subdomains-with-iis7 [...]

Leave a Reply