
Teach you how to use curl to hang a proxy!
Brothers engaged in network development should have run into this scenario: the local debugging interface is dead, change an export IP immediately effective. This time you need to offer up the proxy IP this magic weapon. Today we take the command line tool curl to start, say through how to proxy IP access to the target site.
Let's start with the hard stuff. The most basic proxy setup command looks like this:
curl -x http://123.45.67.89:8080 https://target-site.com
Here.-x parameterIt is the golden key to specify the proxy server. Note that the proxy address should have a protocol header (http://或https://) and the port number should not be missing. Some brothers often leave out the colon, the result of half a day can not connect.
How Certified Agents Play
If the proxy server wants account password verification, that's how old drivers operate:
curl -x http://user:pass@ipipgo-proxy.com:9023 https://data-source.net
Here the account password is disliked directly in the proxy address, which is suitable for temporary testing. But be careful, this way of writing will expose the password in the history command.Don't do that in a production environment.! It is recommended to write the -proxy-user parameter separately:
curl -x http://ipipgo-proxy.com:9023 --proxy-user user:pass https://api.example.cn
The timeout parameters have to be matched.
If you use a proxy, you are most afraid of encountering stupid IPs, and then the timeout setting is a life preserver. This is the recommended configuration:
curl -x http://ipipgo-proxy.com:9023 --connect-timeout 15 --max-time 30 https://target.com
connect-timeoutControls the timing of the connection to the proxy, themax-timeis the survival time of the entire request. These two parameters are used in conjunction with each other to effectively prevent the program from getting stuck. Tests have found that with ipipgo's quality proxies, the timeout parameter is tuned to within 5 seconds and it runs smoothly.
Practical guide to pothole draining
Newcomers often step on the pit, brother have organized for you:
| error message (computing) | check the direction of the investigation |
|---|---|
| Connection refused | Check that the proxy port is correct and that the firewall is released |
| 407 Proxy Authentication Required | Is the account password in the right format? Remember to escape special characters. |
| SSL_ERROR_SYSCALL | Try replacing the https proxy with the http protocol. |
QA session
Q: Why is the response slower after using a proxy?
A:八成是代理服务器质量不行。推荐用ipipgo的独享IP池,他们家的线路做了BGP优化,实测能压到200ms以内。
Q: What if I need to switch proxies frequently?
A: You can write a shell script to rotate IPs and work with ipipgo's API to get new proxies dynamically. Remember to add -proxy-anyauth parameter in curl command to handle authentication automatically.
Q: Are proxy settings effective for https sites?
A: No problem at all! Modern proxies all support tunnel mode, and https traffic will be forwarded as is. However, be aware that some older proxies may not support SNI extensions, so you'll have to add the -ssl-no-revoke parameter to the curl to try it out.
Last but not least, ipipgo has recently added a new socks5 proxy package, which is much smoother to use. If you want to try it, you can use this command to test it:
curl -x socks5://ipipgo-socks.com:1080 https://speedtest.ipipgo.com
Remember, you have to look at the long-term stability of the proxy service. Some small workshop IP with two days on the cool, ipipgo this side of my measured continuous use of three months, IP survival rate can be 98% above, do crawler project brothers can close their eyes into.

