I am having difficulty making connections to websites using Firefox over a tunneled SOCKS proxy. SOCKS4/SOCKS5 makes no difference.
I set up the tunnel with
ssh -D 1234 id@remotehost.example.com
then point Firefox's SOCKS proxy to localhost on tcp/1234.
One key point to note here is that the tunnel I am setting up is on a remote server I have been using for this purpose for many years. I have proxied FF and other browsers through it for many thousands of sessions on a dozen or more different platforms across all major OSes. Once I get it working, it always works smoothly. However, on this particular instance of FF, I get odd and intermittent problems.
The problem is that FF doesn't seem to "want" to establish a connection. I type in a URL or click a link and I instantly get "Unable to connect" / "Firefox can't establish a connection to the server at …" When I say "instantly," I mean this pops back to me in some small fraction of a second.
So I hit "Try again" or the little reload arrow. And I do it again, and again, and again, as rapidly as I can. And after a few tries — sometimes 3-4, sometimes as many as 15-20 — I get a connection and everything works! So the tunnel / SOCKS connection is available, it's just that FF refuses to use it until it is bullied into doing so. Once I get a connection, further reloads do not cause it to be lost.
I have some add-ons, but a) I've disabled them selectively with no help, and b) I have (of course) tried safe-mode. There is no change.
Any suggestions?
Best Answer
I have to use a proxy everyday at work in order to connect to servers on the other side of a firewall. I also use Firefox, Chrome and Ubuntu 16.04.
EDIT: I forgot one part of this. I have had to add a timeout to a ssh config file or my tunnel will timeout and I lose my connection. Once I added the following stuff, my connection stays open:
In
~/.ssh/config
add the following information (if the file does not exist, create it.). This will send a server keepalive to your tunnel every 15 seconds.I open my tunnel connection with the following command:
Then in Firefox under the Connection Settings in the Manual proxy configuration I only fill in the SOCKS Host: with 127.0.0.1 and Port: 1234. Then I make sure that SOCKS v5 is selected. Also note that I don't have anything in the No Proxy for: box.
I am able to connect to my hosts that way without any problems.
Then for Chrome I run a command line so I don't have to set the settings to Chrome every time I want to go through the proxy, then no proxy. To connect Chrome to the proxy I run the following line:
Hope this helps!