Curl has the best proxy support among many HTTP clients and download tools. This is how you use a socks5 proxy and also resolve hostname in the URL using the socks5 proxy. For some use case, resolving hostname via the proxy is essential.
Suppose you have a socks5 proxy running on localhost:8001.
In curl >= 7.21.7, you can use
1 |
curl -x socks5h://localhost:8001 http://www.google.com/ |
In curl >= 7.18.0, you can use
1 |
curl --socks5-hostname localhost:8001 http://www.google.com/ |
Many tools use libcurl internally or use curl command in their installer script. If it’s difficult to modify the command line itself, you can set proxy using environment variables.
1 |
env ALL_PROXY=socks5h://localhost:8001 PROGRAM [OPTION]... |
If you want to overwrite system proxy settings, you may also need to set two more variables:
1 |
env http_proxy=socks5h://localhost:8001 HTTPS_PROXY=socks5h://localhost:8001 ALL_PROXY=socks5h://localhost:8001 PROGRAM [OPTION]... |
Note that http_proxy
is lower case, the other two is upper case.