Proxy configuration files

Last week I was working on a network connected to two adsl lines – one standard internet connection and one secure connection to another company – and needed to configure the computers so that specific external requests would be made through specific lines. The IP addresses were too broad to simply add entries to the routing table, so it had to be via URL. The obvious way is via a proxy server, but I have no experience with that kind of setup and the company in question probably wouldn’t be amenable to the inevitable downtimes while I tried to figure it all out. In the end I used a proxy configuration file, which consists of a small javascript function, for example:

function FindProxyForURL(url, host) {
     if (shExpMatch(url,”**”))     {return “PROXY”;}
     return “DIRECT”;

The browser checks the config file for every URL, and uses a proxy of for every URL while using the default settings for all others. I could use this to link to a proxy server on the secure line. This worked well, except that Internet Explorer’s proxy config file path setting doesn’t support UNC formats like \\computer1\files\proxy, so I couldn’t simply host a ‘proxy.pac’ file on one computer and have all the others link to it. I didn’t want to set up and configure an IIS server just for this, and equally didn’t want individual files on each computer as any changes would be difficult to implement. Eventually I discovered that IE does support UNC in the form of:


Which looks silly, but works 🙂 Unfortunately Java, which gets its proxy info from the browser, doesn’t understand such a string, so I had to manually set a proxy in the Java config and hope that Java would only be needed on certain websites (could backfire, this).

I may need to set up a proper proxy server if it becomes any more complex, but for simple tasks a proxy configuration file seems to work well.