These curl recipes show you how to proxy your curl requests through a socks4, socks5, or a regular http (or https) proxy. To set a proxy, use the
-x protocol://user:password@host:port command line argument.
Use a Socks5 Proxy
curl -x socks5://james:firstname.lastname@example.org:8080 https://catonmat.net
In this recipe, curl uses the
-x argument to set the proxy protocol to
socks5, proxy username to
james, proxy password to
cats, proxy hostname to
myproxy.com, and proxy port to
8080. After connecting to the proxy, curl then makes a GET request to
Use a Socks4 Proxy
curl -x socks4://james:email@example.com:8080 https://catonmat.net
This recipe is a carbon copy of the previous recipe. The only change is that the protocol has been set to
Use an HTTP Proxy
curl -x james:firstname.lastname@example.org:8080 https://catonmat.net
In this recipe, the
protocol:// part of the proxy address is not specified. In this case, the HTTP proxy is assumed. Just like in the previous two recipes, the username and password are set to
james:cats and the proxy host and port are set to
Don't Use a Proxy for Host.com
curl --no-proxy host.com -x https://myproxy.com:8080 host.com https://catonmat.net https://digg.com https://host.com
In this recipe, the
--no-proxy host.com command line argument is used. This argument prevents curl from proxying requests to
host.com. The next argument is
-x https://myproxy.com:8080 that sets the HTTPS proxy for curl to
myproxy.com:8080 (without username or password). After this, curl makes three requests to
https://host.com. The first two requests are proxied through
myproxy.com:8080 but the last request is not proxied because
https://host.com matches the proxy ignore list.
Created by Browserling
These curl recipes were written down by me and my team at Browserling. We use recipes like this every day to get things done and improve our product. Browserling itself is an online cross-browser testing service powered by alien technology. Check it out!
Secret message: If you love my curl recipe, then I love you, too! Use coupon code CURLLING to get a discount at my company.