Tech Off Thread

6 posts

Dynamic and Programattic DNS Aliasing

Back to Forum: Tech Off
  • User profile image
    W3bbo

    'lo

    I noticed a large number of sites out there, such as DeviantArt and a number of SA-style "teh funnay" sites, such as YTMND, are able to dynamically display pages based on the second-level domain.

    How is this possible on the Windows platform? Obviously you'd need to create a Website that catches all Host-Headers with a pattern like "*.foo.TLD", but IIS doesn't support this.

    Secondly, whilst you could access the host-header with Request.ServerVariables("HTTP_HOST_HEADER") it isn't so easy to work with.

    Finally, how do they have their DNS Servers set up to allow this and is this possible with the Windows DNS Server?

  • User profile image
    badriram

    Well IIS does allow using no host headers on a particular ip. So any dns name on that IP would be answered. Then you can have your application parse it, and show different sites based on entry

  • User profile image
    kriskdf

    W3bbo wrote:
    'lo

    How is this possible on the Windows platform? Obviously you'd need to create a Website that catches all Host-Headers with a pattern like "*.foo.TLD", but IIS doesn't support this.

    Secondly, whilst you could access the host-header with Request.ServerVariables("HTTP_HOST_HEADER") it isn't so easy to work with.

    Finally, how do they have their DNS Servers set up to allow this and is this possible with the Windows DNS Server?



    IIS doesn't appear to support using wildcards for host names, but you can have IIS catch every request regardless of host header.

    You don't have to use the HTTP_HOST_HEADER.  You could write a isapi filter that takes the host name and puts it into a querystring variable and use it like Request["HOST"] or something like that.  There are probably other ways to do it as well.

    I don't know much about Windows DNS, but you could probably add new host names through script.  I don't know the advantage of managing a site this way.  There might be a way to specify *.domain.tld = 127.0.0.1 throught DNS as well.  This seems easier to manage.

  • User profile image
    dotnetjunkie

    It's actually very simple on Windows!

    I've done this a few times already, one is a fan site where every member has its own personal page / mini website as a subdomain.

    You create a wildcard record in your windows DNS, point to the IP of your default website (or any website that listens on that particular IP, *no* host headers required!!), and then in ASP.NET you get the URL from the request object and do the stuff you need to do Smiley

  • User profile image
    W3bbo

    kriskdf wrote:
    W3bbo wrote:'lo

    How is this possible on the Windows platform? Obviously you'd need to create a Website that catches all Host-Headers with a pattern like "*.foo.TLD", but IIS doesn't support this.

    Secondly, whilst you could access the host-header with Request.ServerVariables("HTTP_HOST_HEADER") it isn't so easy to work with.

    Finally, how do they have their DNS Servers set up to allow this and is this possible with the Windows DNS Server?



    IIS doesn't appear to support using wildcards for host names, but you can have IIS catch every request regardless of host header.


    But that means you can only have one catch-all site per computer.

    Not good.

    Unless... could a global ISAPI Filter capture this and forward the requests appropriatly?

  • User profile image
    dotnetjunkie

    W3bbo, did you actually READ my reply?!!!

    You can have as many catch-all sites on the same server as you wish, just on different IP's or ports.

    Only one of these three things has to be different between websites:
    * IP
    * Port
    * Host header

    So, without host headers, it leaves you with 2 options.
    You can assign as many IP's to the same network interface as you wish, so you can create as many catch all zones in your DNS as required Smiley

Comments closed

Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums, or Contact Us and let us know.