I set up a SOCKS proxy at port 9090 to computer B elsewhere:

ssh -D localhost:9090 user@B

and configured it in my local Google Chrome browser. However, computer B is behind an HTTP proxy, so HTTP requests originating locally get to computer B through the SOCKS proxy but can't be addressed (terminal running ssh -D localhost:9090 user@B shows "open failed: connect failed: No route to host" when such a request is made).

I have tried:

  1. setting up BOTH remote HTTP proxy (behind which computer B is) and SOCKS proxy in Google Chrome,
  2. running ssh -D localhost:9090 user@B with environment variable http_proxy properly set,
  3. adding http_proxy=_proxy_address_ to the user's .bashrc on computer B;

but none worked.

Anyone knows how to configure the SOCKS proxy so as to take into account the HTTP proxy behind which computer B is? Any method which does not involve changing SSHD or global configuration at the server would be prefered.

1 Answer 1


You would do a lot better to "forward" the remote network's proxy server over SSH rather than using the built-in SOCKS server (which just expects a bare gateway-addressable network at the other end).

ssh -L 8080:internal_ip_of_proxy:8080 user@ssh_server

This exposes the proxy server locally, allowing you to set your browser's proxy settings to localhost:8080 and that will tunnel over SSH to the remote proxy.

And you can apply this to any remote service. You could, for example, tunnel Imgur from your server (in effect a single-host proxy):

ssh -L 8080:imgur.com:80 user@ssh_host

And on a local terminal:

curl --header 'Host: imgur.com' localhost:8080

The Host header is required otherwise curl will request a non-existent localhost site. You could also work around that by adding a line in /etc/hosts, resolving imgur.com to But I'm getting off-topic, you don't need any of this for your purposes.

  • 1
    I tried it in some other way but not succeeded. It works like a charm!
    – sourav c.
    Mar 1, 2015 at 13:54

You must log in to answer this question.

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