Setting up FoxyProxy
patrick — Fri, 2015-05-29 16:44
To add a new proxy connection you'll need 2 things. An actual proxy (which we will set up using ssh) and an entry in FoxyProxy. We will set up the FoxyProxy connection first, then the SSH connection.
Go into the settings for FoxyProxy and click the "Add New Proxy" button.
Click the "Proxy Details" tab and under the "Manual Proxy Configuration" section set the "Host or IP Address" to localhost or 127.0.0.1 and set the port to some value. I prefer a port over 9000 and tend to start at 9999 and count backwards. This port number is important as we'll need to use this port number for SSH. Also remember to check the "SOCKS proxy?" checkbox and make sure "SOCKS v5" is selected.
Now click the "URL Patterns" tab, then click the "Add new pattern" button. I will be using a regular expression pattern in order to match a specific IP address range. For the "Pattern Name" I'm using "dev environment". For the "URL pattern" I'm using "^https?://192\.168\.2\.[0-9]{1,3}(:[0-9]+)?/.*" (so it will match http or https, any ip address between 192.168.2.0 to the fictional 192.168.2.999, any port, and whether or not there's anything after a /). Because I'm using a regular expression I need to make sure the "Regular expression" is selected. Also make sure the "Enabled" checkbox is selected as sometimes it may not be. Then click the "Save" button.
If you want you can actually add multiple different URL patterns. So you could add http://special.internal.server/* as a wildcard type URL pattern.
On the "General" tab, select a color that is not being used by any of the other proxies or the default so you can make sure that this rule is actually being used. Blue is the default color so I'll make this Yellow.
Click all the Save buttons until you end up back at the list of proxies in FoxyProxy. I don't remember if Firefox needs a restart, but I do know Chrome requires a restart.
You should now be able to leave FoxyProxy set to "Use proxies based on their pre-defined patterns and priorities" and for anything that doesn't match the pattern it should use your default Chrome settings (i.e. your normal proxy if you have one or no proxy [most people don't have a proxy]) - like connecting to google. And should use your proxy settings if the URL does match (in these images, you'll note the http://192.168.2.13 pulls up an "Index of /" page using the yellow FoxyProxy icon).
Now that FoxyProxy is setup let's actually set up the SSH proxy (PuTTY can do this as well, but I don't remember the settings). The ${proxy_port} is the only part of this that needs to match up with the FoxyProxy proxy entry. If you need compression for the SSH connection, just add the "-C" switch. If you need to make ssh connect to a specific port on the server, use the "-p ${ssh_port}" switch.
ssh -D ${proxy_port} ${user}@${ssh_server}