randy/firefox-proxy.md

1.2 KiB

FireFox Proxy File for Tunneling

I have a number of http 'properties' which are behind various walls through which I have to tunnel, especially using sra's favorite sonic screwdriver, ssh. In fact, I think this hack was first sorted by sra.

FireFox provides a crufty hack which can be abused for this purpose.

In FireFox Settings / Connection Settings I choose Automatic proxy configuration URL and fill it in with

file:///Users/randy/.proxy.pac

That file contains <gasp> JavaScript hacks for all the tunneled sites.

function FindProxyForURL(url, host)
{
  if (shExpMatch(host, "*.first.site"))
    return "PROXY 127.0.0.1:8888; DIRECT";
  if (shExpMatch(host, "*.second.site"))
    return "PROXY 127.0.0.1:10080; DIRECT";
  if (shExpMatch(host, "*.third.site"))
    return "PROXY 127.0.0.1:10080; DIRECT";
  else
    return "DIRECT";
}

And when i enter a new network, i start ssh tunnels a la

ssh -f -N -L8888:127.0.0.1:8888 bastion.first.site
ssh -f -N -L8888:127.0.0.1:10080 bastion.second.site
ssh -f -N -L8888:127.0.0.1:10080 bastion.third.site

And Bob's your uncle.


2020.03.07