1

I use different proxies for different purposes.

  • I use shadowsocks proxy for my general purpose web surfing.
  • For going to bank websites, I disable proxy.
  • For accessing some websites related to my work, I should use an ssh tunnel proxy.

So I have a Network Proxy settings GUI opened always and constantly changing between different socks ports when I want to use different websites.

Now I want to define some rules to make proxy switching seamless. Is there any straightforward way to do it?

  • Which GUI do you use? Should the rules be based on target host names? – Jaleks Feb 14 at 12:47
1

You can write a proxy.pac (Proxy Auto Configure) file/script and configure that in your browser to direct what proxy (if any) to use when. It would look something like:

function FindProxyForURL(url, host) {
    var socksProxy = "SOCKS ip.of.sock.proxy:port";
    var workProxy = "PROXY ip.of.work.proxy:port";
    var noProxy = "DIRECT";

    if (shExpMatch(host, "*.mybank.example.com")) return noProxy;
    if (shExpMatch(host, "*.work.example.net")) return workProxy;
    if (host == "other.work.example.net"") return workProxy;
    return socksProxy;
}

Of course enter the real IPs and ports of the proxies, and use the correct hostnames.

You can specify the path the this file by starting e.g. Google Chrome with --proxy-pac-url=file:///path/to/proxy.pac; Chrome on Linux doesn't allow you to directly enter this in the configuration.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.