Curl proxy example
Here's how you can use a proxy with cURL:
To use a proxy with cURL, you can use the --proxy or -x option followed by the proxy address and port. For example, if the proxy is located at proxy.example.com on port 8080, you would use the following command:
curl --proxy proxy.example.com:8080 http://example.com
If you're using an HTTP proxy, you can specify the proxy type explicitly using the --proxy-type option, here is an example:
curl --proxy proxy.example.com:8080 --proxy-type http http://example.com
For SOCKS proxies, use the --proxy-type option with the value socks4 or socks5, here is an example:
curl --proxy socks5://proxy.example.com:1080 http://example.com
If your proxy requires authentication, you can pass the username and password using the -U or --proxy-user option:
curl --proxy proxy.example.com:8080 -U username:password http://example.com
If you want to bypass the proxy for specific domains, you can use the --noproxy option:
curl --proxy proxy.example.com:8080 --noproxy example.com http://example.com
If your proxy supports HTTPS, you can use it by specifying https in the proxy URL:
curl --proxy https://proxy.example.com:8443 https://example.com
Alternatively, you can set the proxy using environment variables:
export http_proxy="http://proxy.example.com:8080"
export
https_proxy="http://proxy.example.com:8080"
curl http://example.com
Using a proxy with cURL can greatly expand your networking capabilities by allowing you to route requests through different servers for various purposes. Whether you’re seeking enhanced security, improved performance, or access to region-restricted content, leveraging a proxy with cURL can be a powerful tool in your networking toolkit.