7

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?

8
  • 1
    You are trying to do something that doesn't make any sense. What's your actual problem? What are you trying to make happen? Feb 25, 2012 at 23:54
  • 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. Feb 26, 2012 at 0:12
  • 1
    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. :-(
    – Synetech
    Feb 26, 2012 at 0:18
  • 2
    @Synetech Bad troll is bad. Reverse proxies do this all the time. Feb 26, 2012 at 0:21
  • 1
    @ta.speot.is, fine; drop the “known” from my comment and leave the “easy”.
    – Synetech
    Feb 26, 2012 at 0:37

3 Answers 3

5

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
4
  • 2
    looks impressive. Out of interest, why is that called reverse proxy? a proxy is a middle man.. what is the reverse aspect?
    – barlop
    Feb 26, 2012 at 1:59
  • 4
    @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. Mar 27, 2012 at 17:21
  • Can't this be achieved by making an entry in HOSTS file as 127.0.0.1:59873 test.com. Why need reverse proxy ?
    – SimpleGuy
    May 16, 2021 at 16:52
  • 1
    @SimpleGuy The HOSTS file deals with ... hosts. Not ports. May 21, 2021 at 4:26
1

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.

1
1

You can use a tool like socat (there are versions for MS-Windows but I haven't tried them) to create a reverse proxy / port forwarder. The command would be:

socat TCP-LISTEN:80,fork TCP:127.0.0.1:59873

This is likely to be easier than installing and configuring a full-blown web-server to do the same job.

So if you map test.com to 127.0.0.1 in %WINDIR%/System32/drivers/etc/hosts (or similar) you can then access http://test.com/ to reach your application listening on port 59873.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .