How do I forward requests to different ports based on a domain they came from?

Posted on 2011-10-10
Last Modified: 2012-05-12
Hi All

Below is a question regarding port forwarding in Linux that someone asked and got a reply
already. I'm just reposting a version modified to my situation.
Could someone help me out on how to do this in Windows Server 2008 please?

My company has a IIS server running an application. They would like to host it from different ports to different clients; how to forward the requests to a specific port based on the domain name?

In a nutshell I want to go to 8080 and to go to port 8081 seemlessly with sessions etc... (I do not want people to see the trailing port numbers by the way)
We don't host firstdomain nor the seconddomain as they are our customers buying the app so I can't change their DNS records etc.

Also if it turns out that we can modify their dns entries, would it be possible to create a dns record pointing to our server and a port?

Appreciate any help,

Question by:Paweld
    LVL 21

    Assisted Solution

    Also if it turns out that we can modify their dns entries, would it be possible to create a dns record pointing to our server and a port?

    Nope, DNS has nothing to do with ports.  The best way to achieve this is probably using some sort of rewrite rules or redirection in IIS, however I'm not an expert on that part so hopefully others can help.

    LVL 23

    Expert Comment

    if you are using specific domain names, then using port numbers isn't really required as you can use host headers and bindings on IIS.

    So, you would have your IIS server with the IP address of

    You would create DNS entries for and and give them the same IP address of

    On your IIS server, you would have multiple websites and under the properties, you would specify the URL that the website should accept traffic for.

    Failing that, you could do this at a firewall level.

    Author Comment

    Thanks guys,

    Jakethecatuk - can I only just ask why do I have to create DNS entries?
    I found the IIS Bindings as you said, and I can add one of my own so it looks something like this:

    Protocol: http;
    IP Address: Any assigned or, so I chose the latter (I can also type external IP address, which I probably should do?)
    Port: I put a port name I want

    Is this what you were talking about? If so, then why do I create DNS entries? Is it because I don't host I will only host the 'app' bit if it's at all possible (
    LVL 23

    Expert Comment

    you need DNS entries for and etc as they need to know where to find the website - no DNS, then no way to your servers.

    Now you've said something which is will probably screw everything up.  You have said '... I will only host the 'app' bit if it's at all possible (' - who is going to be hosting  If it's not on the same server as your APP, then things get very interesting on how to achieve your goal.

    Author Comment

    Ok, talked to developers and asked how exactly they wanted it:

    We will have something like (one for each client obviously) has to point to a corresponding site on our server.

    So technically this could be done with IIS Binding?
    LVL 23

    Accepted Solution

    You can't do what you want to achieve. will have an IP address - i.e. will have an IP address of

    If you type into a browser, your PC will find the IP address from DNS and connect to that site.  Regardless of anything after the '/', the PC will always connect to

    One way around your problem would be to have a new domain called which you would point to the IP address of  You can then use IIS bindings to keep traffic separate on your webserver.

    Author Closing Comment

    As pointed out by jakethecatuk what we wanted to achieve was not doable.
    Instead we will be asking customers to create a subdomain and then point them to our servers
    Thanks and sorry for delay!

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    I was supporting a handful of Windows 2008 (non-R2) 2 node clusters with shared quorum disks. Some had SQL 2008 installed and some were just a vendor application that we supported. For the purposes of this article it doesn’t really matter which so w…
    Sometimes drives fill up and we don't know why.  If you don't understand the best way to use the tools available, you may end up being stumped as to why your drive says it's not full when you have no space left!  Here's how you can find out...
    This tutorial will walk an individual through configuring a drive on a Windows Server 2008 to perform shadow copies in order to quickly recover deleted files and folders. Click on Start and then select Computer to view the available drives on the se…
    This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now