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

29,895

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.

Share:
29,895

Related videos on Youtube

sandeep.malladi
Author by

sandeep.malladi

Updated on September 18, 2022

Comments

  • sandeep.malladi
    sandeep.malladi over 1 year

    I want to give a domain name to the IP address and port for an application in Windows 7. For example, test.com should map to 127.0.0.1:59873.

    Is there anyway that we can do it by using a web server or DNS server?

    • David Schwartz
      David Schwartz about 12 years
      You are trying to do something that doesn't make any sense. What's your actual problem? What are you trying to make happen?
    • sandeep.malladi
      sandeep.malladi about 12 years
      I am using one application which is running on 127.0.0.1:5986.I want use this address in different application but this application doesn't accept ":" in 127.0.0.1:5986.So I want to create an name with the ip and port.
    • Synetech
      Synetech about 12 years
      Unfortunately there is no known/easy way to make an alias for an IP/port pair. The closest you can come is making an alias for an IP address with the HOSTS file. :-(
    • David Schwartz
      David Schwartz about 12 years
      Use 127.0.0.2:5986 if you can't specify a port.
    • ta.speot.is
      ta.speot.is about 12 years
      @Synetech Bad troll is bad. Reverse proxies do this all the time.
    • Synetech
      Synetech about 12 years
      @ta.speot.is, fine; drop the “known” from my comment and leave the “easy”.
    • AStopher
      AStopher about 8 years
      Sounds like to me you need an SRV record.
  • barlop
    barlop about 12 years
    looks impressive. Out of interest, why is that called reverse proxy? a proxy is a middle man.. what is the reverse aspect?
  • jadro12
    jadro12 about 12 years
    @barlop what we used to call just "proxy" or proxy server normally sits close to the client, or in the client infrastracture and it is just used by a set of clients to access multiple content. A reverse proxy works close to the server, any client that want to access that content will reach first the reverse proxy.
  • DavidPostill
    DavidPostill about 8 years
    One small niggle is that you didn't block quote the text quoted from the link. I've fixed that for you. For future reference please read How to reference material written by others
  • SimpleGuy
    SimpleGuy almost 3 years
    Can't this be achieved by making an entry in HOSTS file as 127.0.0.1:59873 test.com. Why need reverse proxy ?
  • ta.speot.is
    ta.speot.is almost 3 years
    @SimpleGuy The HOSTS file deals with ... hosts. Not ports.