I wanted to test something, and needed all the requests for that URL to go via a proxy. I also did not want the other urls to go via the proxy. I was looking for a way to do this.

I came across Proxy Auto-Config. A proxy auto-config (PAC) file defines how web browsers and other user agents can automatically choose the appropriate proxy server (access method) for fetching a given URLwikipedia.

You specify the rules in file proxy.pac. Point your browser proxy config to this file and you are done.


function FindProxyForURL(url, host)
if (dnsDomainIs(host, ".example.com"))
    return "PROXY xx.xx.xx.xx:xx"
return "DIRECT"

In Firefox Preferences -> Advanced -> Network -> Settings locate a Radio button which says Automatic proxy configuration URL. Put in the URL to access your file. for a local file use the format similar to file:///<PATH>/proxy.pac

From my limited information on the topic I realised that PAC is highly configurable and functional. Hope to explore a few more applications of the same in the future.

Edit (10-Feb-2015): In OS X, System Preferences -> Networks -> Advanced -> Proxies -> Automatic Proxy Configuration You can add the file-link to proxy.pac here. This enables custom proxy configurations for Chrome and/or Safari.