Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Right now I am using plink in a batch routine that reconnects to my SSH server if I loose connection. I use my plink connection & socks proxy (firefox) to forward all my browser traffic. Works great EXCEPT for one thing!

If I can't get to my ssh server for some ODD reason I have to go to options in firefox and revert back my settings to NO Proxy. It can be done, but its annoying!

So how would I keep my SOCKS Proxy connection in firefox, but if I cant connect to my SSH Server, how can I automatically switch to the autodetect proxy/no proxy settings in firefox?

I would think that I could use the Firefox command line arguments and a batch routine to do so, but I do not believe this is possible. I do see via this link where the proxy settings are stored, but does that mean I have to change the proxy settings depending on my senario above within the .js file?

share|improve this question
Maybe creating a service to monitor the ssh connection would be a better approach. So that way I can use to switch my firefox network proxy settings? – Benjamin Jones Nov 4 '13 at 22:22
up vote 1 down vote accepted

I don't know of any way to do this that it built into the browsers, or even through automation like you mention, however the FoxyProxy extensions does make managing proxy settings much easier.

Also, you might be able to hack up a PAC file that can check if your proxy server is up and if so use it, otherwise bypass.

Edit: It looks like, according to the original PAC spec from Netscape, if you return multiple proxy servers separated by semi-colons it will try them in order, and fallback if one fails. So, you could just us a PAC file that looks like this (should work, but untested):

function FindProxyForURL(url, host)
    return 'SOCKS5 myhost:8080; DIRECT';

Note: Use PROXY myhost:myport for non-SOCKS proxies.

share|improve this answer
Thanks! The PAC file should work! – Benjamin Jones Nov 5 '13 at 1:55
Are you sure about the above code for a SOCKS Proxy? I tested the PAC File from FoxyProxy(works) and enabled it. If I am not connected to my SSH Server, Firefox bypasses like you mention, but as soon as I connect and the port is forwarded dynamically to ssh server, foxy proxy with the same port work, but does not show/forward http traffic. I know its NOT the port becuase if I set FoxyProxy to Manual Proxy with SOCKS enabled to the same localIP and Port as the PAC File, it Works! – Benjamin Jones Nov 5 '13 at 14:25
Got it! the pac file should look like this for a SOCKS5 Proxy: function FindProxyForURL(url, host) { return 'SOCKS5 mylocalhost:PORT; DIRECT'; } – Benjamin Jones Nov 5 '13 at 14:30

Ok with help from heavyd, this is how you would use a SSH client(plink, putty,linux client,etc), to forward all your http:,https: traffic to where you SSH Server is located(another ISP), by using Firefox and FoxyProxy, with the condition that if the SSH connection fails, the SOCKS proxy in firefox will default to NO Proxy setting(direct).

NOTE: FoxyProxy works with other Web Browsers, but Firefox with FoxyProxy add-on was used for the below instructions.

1.) Make sure you have a SSH Server configured so you can reach it from another ISP.( Suggestion: reconfigure SSH Server Port. Who doesn't know that default port 22 is SSH, so change it!)

2.) Make sure that your SSH Client is configured and can reach your SSH Server from another ISP. (example Coffee shop=SSH Client, Home=SSH Server == successful connection).

3.) Forward a port dynamically from your SSH Client. All this means is set tunnel to forward source port of ANY port number. Example -d 4543 . WRITE DOWN this port number! You will need it for below!

4.) Download & Install the latest version of Firefox.

5.) Download FoxyProxy Add-On for Firefox. If FoxyProxy enabled. You will see a fox icon on right hand side of address bar. Click icon to configure foxyproxy.

6.) Create PAC File from text editor. Save file as extension .PAC . Save it somewhere you'll remember the location. Use the following below for content of PAC file. Replace mylocalhost with and Port with the DYNAMIC PORT you create above.

function FindProxyForURL(url, host) { return 'SOCKS5 mylocalhost:PORT; DIRECT'; }

7.) Once you have .pac file. Use firefox to find file. Copy location address into the Firefox address bar and your output should be where Firefox see's your .pac file. (Windows example: file:///C:/). (Don't put your file in root! C:=root) Copy firefox location address.

8.) Open FoxyProxy by clicking on icon in Firefox. Click Add New Proxy. Select Automatic Proxy Configuration and insert location of .PAC File that Firefox can see.(example file:///C:/). Click OK.

9.) Now test with SSH Server connection and with out SSH connection! Use to make sure SOCKS Proxy works.

share|improve this answer

You must log in to answer this question.

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