You are on your company’s WiFi network. You’ve been able to access intranet sites so far, but now you’d like to access an external site via the company’s HTTP proxy. Your company, however, does not provide a proxy auto-configuration URL. You are therefore stuck with having to add or remove the proxy manually in your iPhone WiFi settings each time you’d like to access external or local sites, respectively.
So how can we make things easier? Simple, create your own proxy.pac file.
Create a text document on your computer. In this file, write the JavaScript code necessary to help Safari use your proxy only when needed. See this Wikipedia page for examples. Here’s what mine looks like:
function FindProxyForURL(url, host) { proxy = "PROXY companyproxy.address.com:8080"; // Next, we want to send all traffic to company.net browser direct if (dnsDomainIs(host, ".my.intranet.domain.com")) { return "DIRECT"; } // Loopback and localhost goes browser direct always. if ((host == "localhost") || (shExpMatch(host, "localhost.*")) || (host == "127.0.0.1")) { return "DIRECT"; } // Test to see if host is an IP address reip = /^d+.d+.d+.d+$/g; if (reip.test(host)) { // Check for local IP address if (isInNet(host, "192.168.0.0", "255.255.0.0")) { return "DIRECT"; } } // Default return condition is the proxy, since it's assumed that everything // else is on the Internet. return proxy; } // End of function
Save and name the file as proxy.pac. One site recommended that the file encoding be set to UTF-8, which I followed and it seems fine. Take this file and copy it to anywhere on your iPhone using tools such as iFunbox or iFile or SSH. I put mine in /var/mobile/Documents.
Now go back to your iPhone WiFi Settings in Settings –> Wi-Fi. Tap on the > button of your WiFi network to view its settings. Swipe all the way down and change HTTP Proxy to Auto, and in the URL field type in the file location, e.g. file:///var/mobile/Documents/proxy.pac. Exit, and all your programs should now automatically detect whether a proxy should be used whenever you are on this WiFi network.
Leave a Reply