Proxying fake domain to a localhost port

I'd like to do much the same thing described at Redirect Domain Name to Localhost for web app development purposes, but with the twist that I'd like requests to fakedomain.com:80 to be routed to localhost:8080, say, so that I don't have to actually use my development machine's port 80.

I'd welcome answers that take the form of:

  • Small changes to configuration files like /etc/hosts, and/or
  • An easy-to-configure proxy server I could run

Note: Pow takes the approach of setting a firewall rule to forward all incoming traffic on port 80 to port 20559. That may be an acceptable solution, but ideally, I'd like to forward only a specific domain + port combination.

2

2 Answers

The whole 127.0.0.0/8 range belongs to your local machine. You don't have to use 127.0.0.1 alone.

You can point your (fake) domain to 127.0.0.2 in your hosts and setup your server to bind just to that IP as opposed to all IPs. In Windows and Linux, the most specific binding wins if there's a conflict, so your binding for 127.0.0.2:80 overrides the one for *:80.

2

You may have to use an external device. I'd set up port forwarding on your firewall / router, on port 80, to point to your computer's port 8080, where fakedomain has an entry in your hosts file pointing to your external firewall / router.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like