Ever wonder how those automatic proxy configuration URL’s work? Basically the URL must return javascript code served up with a Content-Type of “application/x-ns-proxy-autoconfig”, which the browser will run to decide whether to proxy each URL it fetches, and which proxy to use. The javascript should be returned as just plain text, not wrapped in <script> tag’s or anything.
The one function you need to implement is FindProxyForURL(url, host), which gets called for every URL the browser fetches, and must return a string containing one of “DIRECT”, “PROXY host:port”, or “SOCKS host:port”. Actually, the string can also contain a list of these separated by semi-colons, in which case the browser will try each one in sequence until it is able to fetch the page. There are some convenient functions predefined for you to help in examining to url and making proxy decisions based on domain, network of resolved ip server host ip address, time of day/week, etc.
The specification can be be found here.