I managed to achieve this by using Windows included Networking tool netsh
.
As Mat points out : The hosts file is for host name resolution only, so a combination of the two did the trick for me.
example.app:80
| <--Link by Hosts File
+--> 127.65.43.21:80
| <--Link by netsh Utility
+--> localhost:8081
localhost:8081
127.65.43.21 example.app
127.0.0.0/8
(127.x.x.x
) can be used.127.65.43.21:80
is not occupied by another service.netstat -a -n -p TCP | grep "LISTENING"
netsh interface portproxy add v4tov4 listenport=80 listenaddress=127.65.43.21 connectport=8081 connectaddress=127.0.0.1
http://example.app
Notes:
- These commands/file modifications need to be executed with Admin rights
- netsh portproxy needs ipv6 libraries even only to use v4tov4, typically they will also be included by default, otherwise install them using the following command: netsh interface ipv6 install
You can see the entry you have added with the command:
netsh interface portproxy show v4tov4
You can remove the entry with the following command:
netsh interface portproxy delete v4tov4 listenport=80 listenaddress=127.65.43.21