Monday, May 21, 2012

Serving Unlimited Domains From IIS, pt 2

Last time, I posed the question of how to serve unlimited domains from IIS. I got to digging around, found some options myself, and had some better options revealed to me by folks in the Tulsa WebDevs Facebook group and by my partners here at work. So here are the options, as I currently understand them:

1) Build It Into The Code
Probably the best option is to programmatically create bindings in IIS6 and/or in IIS7. This way everything is integrated into the webapp, meaning there's no muss or fuss outside of the app. It requires a bit more work in the app itself, but the benefits of keeping things clean and keeping all the functionality around this action inside the single codebase are almost definitely worth it.

2) PowerShell
Another option is to set up a script for powershell to have it handle this stuff based on the script detecting changes to the database. This would work well also, but has the drawback of creating two codebases to maintain.

3) Remove Domain Bindings
This StackOverflow answer led me to try removing the existing domain from the webapp's bindings in IIS. Making this change resulted in being able to reach my webapp by just visiting the IP address (so the binding was no longer an issue). And the one domain we have set for this webapp so far still reached the desired site as well. So it seems that the solution could be as simple as to have no host/domain listed in the bindings on IIS. As long as only one site does this, all traffic that does not match another binding loads that site. A big upside here is that it takes less time/effort than any of the coding solutions mentioned above. The downside is that you can only have one site on the server perform this way, and you can no longer have the server locked to only serving content with recognized domains.

Friday, May 18, 2012

Serving Unlimited Domains From IIS, pt 1

In an upcoming version of a currently-in-development webapp, I need to serve multiple domains from a single site. The code on the site will recognize the individual domains and vary the content accordingly. I do not know all of the domains that we will be serving, as clients can add new domains to their site. The coding parts, I know how to do - when clients add a domain, there will be a corresponding entry into our database and that will act as a key to control which set of content is shown.

The thing is, I suck at system administration. If I knew the domains ahead of time, I could simply point them to our server's IP and then create bindings in IIS to handle each. But since I do not know the domains ahead of time, I'm rather at a loss. I welcome any suggestions. Expect part 2 of this entry in the coming weeks, to reflect whatever solution I find.