How can I map a domain name to an IP address and port?

Solution 1:

Most webservers can be run as reverse proxies, suitable for doing this. If you do everything right, you'll end up with something like the below (minus the "remote" part - since this will all be on one machine):

reverse proxy

  • Navigator is your machine
  • Reverse Proxy is nginx running on your machine (127.0.0.1:80)
  • Remote Server is the web site running on your machine (127.0.0.1:59873)

You can use a lightweight webserver like nginx (even runs on Windows), configure it to reverse proxy test.com to 127.0.0.1:59873 and then add the following entry to your HOSTS file:

127.0.0.1 test.com

Solution 2:

I'm posting this for anybody that is looking to set up a reverse proxy using IIS 7 and above.

For example, in my case, I was trying to use Azure Storage Emulator which is 127.0.0.1:10000 and Remote module of ImageProcessor.Web which does not allow ":" in the whitelisted URLs. So I set a reverse proxy for dev.azureblob.com forwarding to 127.0.0.1:10000.

Nicked from here, done and tested: http://www.myconnectionserver.com/support/tutorials/v90/iisProxy/index.html

  1. Make sure the following packages have been installed on the IIS server:

    • Application Request Routing
    • URL Rewrite

  2. Select the website required from the sites list in IIS. This will display a list of options in the right-hand window.

    Double-click the URL Write option.

  3. Click the Add Rule link in the right-hand side menu.

  4. In the following window select the Reverse Proxy option and click the OK button.

  5. Before entering a server name of IP address make sure you check the Outbound Rules checkbox.

  6. Enter the server name or IP address where the HTTP requests will be forwarded.

    You will see that the from field in the Outbound rules section will mimic the server name/IP that has just been entered.

    All that is left to do is fill out the To section in Outbound rules. This is simple as the dropdown list provided will contain the original server name/IP. Simply select it and click the OK button to save the changes.

  7. Process complete.

    There should now be an inbound and outbound URL rewrite rule showing in the URL Rewrite window. With these rules in place the website of choice should now work as a reverse proxy.