2

I want to use an SSH tunnel to work on a project, -L 8080:localhost:80. When opening http://localhost:8080 on my local machine things work, but the server (MediaWiki) is putting a lot of http://203.0.113.37/ (example IP) in the HTML source served and this address does not go anywhere from my localhost.

Is there a way to map 203.0.113.37 to 127.0.0.1 on my local machine? E.g. something like /etc/hosts but then for IP addresses.

(Ideally I want this to work on OS X.)

4
  • 3
    use ssh -D 1080 instead of port forwarding and configure your browser to use a SOCKS proxy via localhost:1080 (all browser traffic will be routed via that ssh SOCKS tunnel). Jun 9, 2015 at 12:38
  • @StéphaneChazelas thanks. This is a good workaround. I'd still like to know if "IP aliases" are possible though.
    – the
    Jun 9, 2015 at 12:50
  • That would have to be done via some LD_PRELOAD wrapper, DNAT at the firewall level (don't know about OS/X), or some other form of proxying (HTTP proxy or SOCKS proxy doing the translation on the fly). Jun 9, 2015 at 13:05
  • Actually, if you configure your browser to HTTP-proxy via localhost:8080, it would probably work. It would issue some GET http://203.0.113.37/... HTTP/1.1... to the remote web server which it should treat properly. Jun 9, 2015 at 13:09

1 Answer 1

0

This sounds liks a problem which can more easily be solved within your HTTP config. See if you can set the hostname on the server to be localhost for the testing period, and/or disable canonicalname redirection.

I think that convincing the webserver NOT to send that canonical IP will prevent the problem you're trying to solve with a networking/hosts fix.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.