Without youtube, facebook or twitter, an iPad misses out on quite a bit of the good ol' social networking experience of the western world. Anyone living in China can attest that a good proxy service is worth substantially more than its own weight in gold. I have to admit that I don't facebook often or have many twitter followers, but Youtube is essential for me. [note: I had no idea what gangnam style was until about 2 months ago] So, it only made sense to set up the iPad to access youtube, blogger, vimeo etc through a proxy.
After finally figuring out how to run Freegate via wine on Mac OS X, I had a viable proxy. Then I set up OS X to forward requests from my iPad to the freegate proxy server running on the host mac. Next, I just manually set the iPad's wi-fi proxy settings to the ip of the host Mac with the appropriate port. Voila, youtube. The thing is... I only wanted to access a few sites through the proxy, so I had to go back into the settings to turn the proxy off. I felt this was all ridiculously tedious, so it only made sense to create a PAC to define which sites to use the proxy.
I attempted this ages ago but was foiled several times. Although I used Mike West's excellent post to create my actual pac file, it never seemed to work with safari on the macbook or ipad. After several hours of tweaking, googling and cursing at safari, I gave up on it. Freegate hasn't been working so I had basically given up on the idea of a PAC. Months later, Freegate is working pretty reliably again, so I gave it another crack and it's working brilliantly thanks to apple discussion posts and numerous other sites that lead me to the correct place.
This post at discussions.apple.com basically fixed everything for me. The http:// vs file:// wasn't relevant to the ipad settings, but cjdaviescs noted that there's a problem with the webserver serving PACs. So I changed the file extension to .txt and everything worked perfectly! Although I was a little bit disgruntled because I spent so many long hours poring over the code looking for some tiny, tiny error, it feels good to have it finally working how I want.
--------------------------------------------------------------------
So, here it goes:
1. create your PAC by opening up a blank plain text document in textedit, or whatever text editor you like. save it as unicode utf8.
2. write the function to use a proxy. the code below just checks to see if the url is for one of the sites you want to access by proxy. if it does not, it access the site normally without a proxy.
function FindProxyForURL(url,host) {
if (shExpMatch(host, "*facebook.com") ||
shExpMatch(host, "*youtube.com") ||
shExpMatch(host, "*.ytimg.com") ||
shExpMatch(host, "*.blog*.com"))
{ return "PROXY 192.168.0.100:8580"; }
return "DIRECT"; }
This example has just a few sites listed. It's not the most elegant, but that's why I included Mike West's post above. Check his guide to see something a little more beautiful and programmer-smart.
function FindProxyForURL(url,host) { -- call the proxy function
if (shExpMatch(host, "*facebook.com") || -- if the host address has facebook.com or
shExpMatch(host, "*youtube.com") || -- youtube.com or
shExpMatch(host, "*.ytimg.com") || -- .ytimg.com or
shExpMatch(host, "*.blog*.com")) -- blogger or blogspot
{ return "PROXY 192.168.0.100:8580"; } -- use 192.168.0.100 with port 8580 as the proxy
return "DIRECT"; } -- if it doesnt have any of the above, dont use a proxy
3. set up a webserver to host your PAC file. open up Sharing in your System Preferences. make sure Web Sharing is checked.
4. place your pac file somewhere accessible to others. Click on "Open Computer Website Folder" and save/move your pac file there.
5. don't forget to set up your computer to accept and forward requests to freegate!
Not everything is written 100% clearly above, and I know it will be a bit confusing for some non-programmers out there. If you have any questions, feel free to drop me an e-mail or leave a comment.
This comment has been removed by the author.
ReplyDelete