How to configure auto-proxying in Chrome

If you need to access SOME websites using proxy (only few of them), you might like to use Proxy Autoconfiguration feature (or PAC). Google Chrome can do it and its a piece of cake to configure it. Create a file my-proxy.pac somewhere with this content:

function FindProxyForURL (url,host) {
var hosts = ["my.site1.com","my.site2.com"];
for(var i=0;i<hosts.length;i++) {
if (shExpMatch(url,"*."+hosts[i]+"/*")||shExpMatch(url,"*//"+hosts[i]+"/*")) {
return "PROXY myproxy.company.com:3128; DIRECT";
}
}
return "DIRECT";
}


Now in Windows you would be configuring the path for PAC file in the Under the hood configuration screen. But its not there in Linux. In this case you need to add one line to your .bashrc:

export auto_proxy=file:///home/lzap/my-proxy.pac

Re-login and you are done. Nice.
20 June 2011 | chrome | google
twitter.com linkedin.com
google.com/+ facebook.com
flickr.com youtube.com