Automatic proxy configuration for capturing packets on iPhones


Problem description

in useCharlesWhen the tool captures packets, some application networks on the mobile phone will be unavailable, andCharlesAfter closing, the mobile phone has no network to use. You need to close the mobile agent before you can access the network normally.

However, the agent needs to be manually configured for the next packet capture, which is quite troublesome. Here, the automatic agent mode of the mobile phone can solve the problem of switching back and forth of agent configuration.


First, create a new oneproxy.pacThe contents of the document are as follows:,urlIs the request path,hostIs the domain name. You can configure whether to perform proxy according to these two parameters.
Code description means when the domain name isxxxSend the request to the proxy server with the address ofCharlesIf the domain name is notxxxThen proxy forwarding is not used,return "DIRECT";Indicates no proxy forwarding.

function FindProxyForURL(url, host){
    if(host == "xxxx" ) {
    return "PROXY";
    return "DIRECT";

Put the configuration file on the server, which is used heremacBuilt in server, turn it onApacheThe server:sudo apachectl -k start

Enter in browserhttp://localhost/, if displayedIt worksIt indicates that the server is started successfully and the configuration file is thrown into the serverApacheRoot directory:/Library/WebServer/Documents

Automatic proxy configuration for capturing packets on iPhones


Open the mobile phone, select the corresponding network in the network, enter the agent setting, select automatic agent, and enterproxy.pacAddress of the document, i.emacofIPAddress+proxy.pac, as shown in the figure below, then store the agent configuration, exit the agent configuration, close the network, and then open the network. The agent configuration will take effect.

Automatic proxy configuration for capturing packets on iPhones


Remember to close the network after modifying the configuration file. The new configuration will not take effect until the network is turned on.

Recommended Today

Best practice | using micro build low code to realize Tencent questionnaire satisfaction survey

After the Tencent questionnaire is combined with Tencent cloud micro build, developers can embed the questionnaire ability in the application through the micro build platform to launch the satisfaction survey, and synchronize the results of the questionnaire to micro build for subsequent analysis. This article will guide you how to add Tencent questionnaire to your […]