Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I installed Ubuntu 12.04 and it is running just fine. I only have a problem, I connect to the internet through a proxy at my college, but there are some url's that I don't need the proxy for, so my question is: How can I exempt a url from my proxy configuration on Ubuntu?

share|improve this question

2 Answers 2

You may need a proxy configuration script (PAC). It is a universal solution, and works in any DE, any platform, with any browser.

In your proxy settings, either in browser, or from Network in Unity, select 'Automatic proxy configuration URL' and type in a path like /home/<Your-user-name>/proxy or some other convinient path.

Open a text editor, ( Search in Dash to find gedit -the default text editor) and write something like this. Save it to the path entered above, when done. Modify to your needs.

function FindProxyForURL(url, host)
{
// Loopback and localhost goes browser direct always.
    var reip;
    if ((host == "localhost") ||
           (shExpMatch(host, "localhost.*")) ||
           (shExpMatch(host,"10.*")) ||
           (shExpMatch(host,"172.16.*")) || 
           (shExpMatch(host,"192.168.*")) ||
           (shExpMatch(host,"144.16.128.*")) ||
           (host == "127.0.0.1")) {
        return "DIRECT";
    } 
// Local Sites
    if (dnsDomainIs(host, ".example.com") ||
       dnsDomainIs(host, ".qwerty.org")) {
        return "DIRECT";
    }
// Test to see if host is an IP address
// Put any ranges you want to skip proxy here.
    reip = /^\d+\.\d+\.\d+\.\d+$/g;
    if (reip.test(host)) {
        if (isInNet(host, "10.0.0.0", "255.0.0.0") ||
            isInNet(host, "172.16.0.0", "255.255.0.0") ||
            isInNet(host, "144.16.128.0", "255.255.240.0") ||
            isInNet(host,"192.168.0.0", "255.255.0.0")) {
             return "DIRECT";
        }
    }
// Default to proxy.
    return "PROXY <server>:<port>";
}

As you see, complex configurations can be made out of PAC scripts. The above script skips proxy for any address of type *.example.com and *.qwerty.org and any ip that matches the ranges. All other requests are routed through proxy server.

P.S: I've seen a empty line at top and bottom in all PAC scripts I've seen so far, so I suggest you add a newline both at top and mottom. Just in case...

share|improve this answer
    
Additional info here: en.wikipedia.org/wiki/Proxy_auto-config –  Mahesh May 23 '12 at 8:25

If you are just using an http proxy you can open gconf-editor (sudo apt-get install gconf-editor, if you don't have it already) navigate to system:http_proxy and add the urls you want to exempt into the ignore_hosts key, separated by commas I believe. (see picture below)

ignore_hosts key

If you are using a socks5 proxy it's a little more complicated to set system wide. However for certain individual programs it's quite easy. For Firefox for example, go to edit:preferences:advanced:(connection)settings then change it from Use system proxy settings or whatever it is to Manual proxy configuration, then enter your proxy information and add the urls you don't want in the No proxy for field, once again separated by commas. (See screenshot below)

no_proxy_for setting

If you use Chromium you can run it with command line switches, for example /etc/bin/chromium-browser --proxy-bypass-list="localhost,127.0.0.1,xxx.xxx.xx.etc" --proxy-server="socks5://localhost:1080".

Some other applications will have similar functionality, and you can use a wrapper program like tsocks for those that don't.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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