Curl proxy example

Using a proxy with cURL involves passing the appropriate command-line options to the cURL tool. A proxy can help route your network requests through an intermediary server, providing various benefits like anonymity, security, and access to geographically restricted content.
Here's how you can use a proxy with cURL:
Basic Proxy Usage

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

Curl HTTP Proxy

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

Curl SOCKS Proxy

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

Curl proxy username password

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

Curl bypass proxy

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

HTTPS Proxy

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

Environment Variables

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

Remember to adjust the proxy URLs accordingly for different proxy types.

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.

Scroll to Top