One of the things that I dislike about the OS X proxy settings is that they are all or none. This poses a problem to me. I like working on the iOS Simulator for speed and convenience. I like using Fiddler to do all sorts of network debugging. I don’t like that the iOS Simulator doesn’t have its own proxy settings. You have to turn on the system proxy to get the simulator to proxy through fiddler, and that wreaks all kind of havoc on Outlook, Slack and Pandora, not to mention it just floods fiddler with all sorts of data.
The fastest and easiest way to deal with this is to just use fiddler’s filters, but for some reason i can’t seem to get them quite right, so I stumbled across this option.
Automatic Proxy Configuration
Auto proxy config is basically just a javascript file with a pac extension. Relevant Wikipedia entry
Unfortunately, Apple seems to get rid of all sorts of useful things because of “Security.” Once upon a time you could setup an automatic proxy configuration with a file url referencing your local file system, but they took that out. 🙁
The easiest thing to do is just start the apache server built into OS X, and throw a pac file into a directory that gets served up by apache
1 2 |
sudo apachectl start open /Library/WebServer/Documents/ |
The first line starts apache, the second will open a finder window where you need to drop your pac file.
There’s all sorts of complicated stuff you can do in a pac file, but the simplest thing to do is just proxy based on urls which you can do like this
1 2 3 4 5 6 7 8 9 10 |
function FindProxyForURL(url, host) { PROXY = "PROXY 1.2.3.4"; //put the actual proxy here if (shExpMatch(host,"*.google.com")) { // put the host you want to proxy here return PROXY; } // Everything else bypasses the proxy return "DIRECT"; } |