Add a proxy to a particular host only in mac
You can use the following proxy.pac
file to send all traffic to apple.com through the proxy 1.2.3.4 while still going directly to all other hosts:
function FindProxyForURL(url, host) {
PROXY = "PROXY 1.2.3.4"
// Apple.com via proxy
if (shExpMatch(host,"*.apple.com")) {
return PROXY;
}
// Everything else directly!
return "DIRECT";
}
- Save this script as
proxy.pac
(or any other name you like) on a web server. This can be a local web server (http://localhost/proxy.pac). This is required as of OSX Lion. - Go to the
System Preferences
. - Select
Network
. - Select the network you want to change (i.e. "WiFi").
- Click
Advanced...
button. - Click
Proxies
tab - Check
[x] Automatic Proxy-Configuration
. - In the
URL:
field, type in the URL to the file you've created in step 1., for example:http://localhost/proxy.pac
. (note: local paths will not work in modern OSX) - Click
Save
andApply
Voila! Your own proxy-configuration
For more information on the format of the proxy.pac
file have a look at http://en.wikipedia.org/wiki/Proxy_Auto-Config as starting point.
Actually you can use the file:///path/to/file
scheme for the URL, instead of having to rely on a web server.
For example:
file:///Users/youruser/var/proxy/proxy.pac
Adding to @heiglandreas's answer...
@jnbek's solution did not work on Mac OSX for me and I was looking for a simple solution.
So, I created a new folder and copied the pac file into that. Then, I started a simple web server on OSX on port 80 from that folder itself.
Just go into the folder & run this command. Please change the port from 80 to something else if its already occupied.
python -m SimpleHTTPServer 80
Now, I could easily get the proxy.pac file from http://localhost/proxy.pac
.
Or, for different port use: http://localhost:PORT/proxy.pac
.