16 февраля 2017 г.

Debugging iPhone/iPad HTTP requests using squid3 proxy

I needed to debug the requests an iOS app was making. An option is to configure your Wi-Fi setings to use an HTTP proxy, and if you have a Debian VPS/server, I think that'd be the fastest way to get this done.

Step 1/2: Install Squid3

apt-get update
apt-get install -y squid3

Allow non-ssl requests: find the http_access block
# Deny requests to certain unsafe ports
http_access deny !Safe_ports
Comment out the last line.

If you're getting the TCP_DENIED/403 error:

ERROR: The requested URL could not be retrieved
The following error was encountered while trying to retrieve the URL: Access Denied.
Access control configuration prevents your request from being allowed at this time. Please contact your service provider if you feel this is incorrect.

You will have to allow your IP address in /etc/squid3/squid.conf:
acl my_ip src
http_access allow my_ip
Replace with your IP address and add the above lines to the very top of the file!

Step 2/2: Configure iOS to use your proxy

Find out your squid port:
netstat -apn | grep squid | grep LISTEN

On your iOS device, go to Settings - Wi-Fi - tap the i in front of the network you're connected to - scroll to PROXY HTTP - add your server IP and port; turn off authentication

That's it. You should now see the requests the iPhone makes in /var/log/squid3/access.log.

Комментариев нет: