managing multiple proxies in linux












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?










share|improve this question























  • Which GUI do you use? Should the rules be based on target host names?

    – Jaleks
    Feb 14 at 12:47
















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?










share|improve this question























  • Which GUI do you use? Should the rules be based on target host names?

    – Jaleks
    Feb 14 at 12:47














1












1








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?










share|improve this question














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?







proxy iproute socks






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Feb 14 at 12:41









Mehdi PourfarMehdi Pourfar

1083




1083













  • Which GUI do you use? Should the rules be based on target host names?

    – Jaleks
    Feb 14 at 12:47



















  • Which GUI do you use? Should the rules be based on target host names?

    – Jaleks
    Feb 14 at 12:47

















Which GUI do you use? Should the rules be based on target host names?

– Jaleks
Feb 14 at 12:47





Which GUI do you use? Should the rules be based on target host names?

– Jaleks
Feb 14 at 12:47










1 Answer
1






active

oldest

votes


















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.






share|improve this answer























    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "106"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f500609%2fmanaging-multiple-proxies-in-linux%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    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.






    share|improve this answer




























      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.






      share|improve this answer


























        1












        1








        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.






        share|improve this answer













        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.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Feb 14 at 12:52









        wurtelwurtel

        10.5k11526




        10.5k11526






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Unix & Linux Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f500609%2fmanaging-multiple-proxies-in-linux%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            How to make a Squid Proxy server?

            Is this a new Fibonacci Identity?

            19世紀