Setup HTTP Proxy for iOS App Testing

If you have a scenario where you are doing iOS development and the application needs to retrieve or send data to a locally hosted website within a LAN, then there are two options:

  1. If  your device is connecting to the internet through a router using Wifi, then you can add a redirect rule on the router. Eg. for domain “xyz.com” go to 192.168.1.12 which is a LAN ip. However very few routers allow this facility so its not really a common solution.
  2. You can setup a http proxy on your Mac machine and configure your iOS device to use the proxy server for accessing the local website.

We are going to look at option 2 as a solution.

Installing HTTP Proxy

Squid is the world’s most popular and the best Proxy Server. It is available free of cost and is open source and is available for all major OS. What we need is SquidMan, which  is a MacOS X graphical installer and manager for the Squid proxy cache. It is available here: http://squidman.net/squidman/

It is downloadable as a .dmg which is a Disk Image file. That means you can double click after downloading and it will start. From the opening screen click on the SquidMan icon to start the application. Then click on Start button to start the proxy server. You can change the Settings by going into Preferences option from the menubar. The default port it runs on is 8080.

Screen Shot 2015-12-30 at 12.45.33 PM

 

 

 

 

 

 

 

 

Screen Shot 2015-12-30 at 12.46.05 PM

 

 

 

 

Screen Shot 2015-12-30 at 12.50.15 PM

 

 

 

 

 

 

 

 

 

 

 

Once Squidman is running then you have to setup your iOS device to use this http proxy for all internet access. Note that ALL internet access will go through this proxy server and not just your local website URL.

Configure HTTP Proxy on iOS Device

In the Settings, go to WiFi option. Whichever network is current, click on the info icon against to configure the connection further.

thumb_IMG_0155_1024

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

In the Wifi configuration screen, scroll down to the HTTP Proxy section. This will be Off by default. Change it to Manual and enter the IP address of the machine on which SquidMan is running and the http port e.g..8080 . Now test it you can open your locally hosted website in your Safari browser on the device. If it opens then the proxy setup is working.

 

oie_k4CSqXqUW3SW

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

All http network traffic on the iOS device from all installed apps will go through the proxy.

 

 

 

Be the first to comment

Leave a Reply

Your email address will not be published.


*