0

Cutting the fluff: Wildcard Host Header Support, is that possible in some way in IIS 8 for subdomains?
I know, it's a bad design which is why I keep the original question below to explain why...


I have two domains, example1.com and example2.com and I want both of them hosted on a simple server running Windows 2012 with IIS 8. I also have just one IP address and things are a bit challenging. However, this is not a production environment but a test environment for me to test complete website projects before they're delivered to a production environment. Then it's done and I start a new project with a new domain.
So I've set up one site in IIS and any incoming traffic goes to that site.I have a second site set up with binding for the second domain and that generally works fine when dealing with many different domains. But now I have a challenge.
I am now working on two projects that both heavily rely on the use of subdomains for the users. So for every user on the site there has to be a specific subdomain. Customer wants this so don't tell me it's a bad idea. Customer is demanding. (And horribly enough, I'm now working on two sites that need this. One would be easy.) So both sites now need to accept all subdomains for a specific domain name. So while most would go to example1.com the url wim.example2.com should go to the second website. And while that would be easy with a second IP address, I just have one.
So how do I get all subdomains go to the right site in IIS 8?

Wim ten Brink
  • 1,055
  • 1
  • 6
  • 13
  • 1
    So in short without the fluff: your question is how to configure IIS to support a wildcard subdomain `*.example.com` on a new/separate site without breaking an existing site where you're already running `www.example.com` and `something-else.example.com`? – HBruijn Sep 17 '18 at 11:55
  • 1
    AFAIK you can't on IIS 8 as wildcard support was only added in IIS 10. Source: https://docs.microsoft.com/en-us/iis/get-started/whats-new-in-iis-10/wildcard-host-header-support and the work-arounds for older IIS versions consisted mainly of creating a default site that would be used handle *any request* rather than specifically those for a particular wildcard domain – HBruijn Sep 17 '18 at 12:00
  • 1
    For development you of course don't really need to support an actual wildcard subdomain to conceptually test the URL recognition parts of your code: you can already do that with a site `customername.example.com` that supports a couple of pre-defined extra domain names such as `user[1-9].example.com` in the advanced --> alternate site identities. – HBruijn Sep 17 '18 at 12:15
  • No wildcard support in IIS 8? Awww... Means I'll have to predefine the subdomains instead. Not a big problem, just annoying... – Wim ten Brink Sep 17 '18 at 12:41
  • I see no challenge at all if you set up a reverse proxy with ARR, https://docs.microsoft.com/en-us/iis/extensions/url-rewrite-module/reverse-proxy-with-url-rewrite-v2-and-application-request-routing Rules can be created to analyze Host headers of the incoming requests and forward them to the two web sites you created, which no longer needs to have host name configured in their bindings, and you can use any port (not limited to port 80). Wildcard host header support in IIS 10 of course can be simpler to use, but it is really not necessary to get the jobs done. – Lex Li Sep 17 '18 at 21:44

1 Answers1

0

I found https://stackoverflow.com/questions/458757/wildcard-subdomains-in-iis7-is-it-possible-to-make-them-like-it-is-in-apache which seems to answer my question so I will close this one. IIS 7 and IIS 8 don't support wildcard bindings for a single domain name as you need to upgrade to IIS 10 for this feature. And IIS 10 requires Windows 2016 (or Windows 10) so without an upgrade of the operating system this will not be possible.
But an option could be https://www.microsoft.com/en-us/download/details.aspx?id=48264, which is a simplified version of IIS 10 which can run on Windows 2012 so that's something to consider. And as my environment is for development, this is a good option for me. Not practical for production servers, though...

Wim ten Brink
  • 1,055
  • 1
  • 6
  • 13
  • https://stackoverflow.com/a/52377393/11182 There is clearly no need to upgrade to IIS 10 and IIS 10 Express is not for production at all. – Lex Li Sep 18 '18 at 01:01