Using curl with Enzoguard

Home » Welcome to Docs » Using curl with Enzoguard

curl is a popular command-line tool used to execute requests over the network. It is one of the earliest programs to ship with support for HTTP proxies.

It supports HTTP proxies with a variety of flags.

The easiest way to use curl with HTTP proxy is to use -x or --proxy flag since that takes in a Proxy URL, including any credentials to authenticate with the proxy. An example:

curl --proxy https://test-app:[email protected] https://debug.enzoguard.com/ip

If you want to separate the credentials (App name and AppKey) from the proxy URL, you can use the --proxy-user flag. The flag takes in the username (App name) as well as the password (AppKey), separated by a colon (:). Here is what the above command looks like with –proxy-user flag:

curl --proxy-user test-app:DZyG3jcN38H2ZJMSDsXVb6WceqI2aJuk2zw97eafZglMWtwU6nl7XfGKtGimybBf --proxy  https://d3wmlvl.enzoproxy.com https://debug.enzoguard.com/ip

If the request being made is an HTTP request i.e. a plain-text request (http://debug.enzoguard.com/ip) instead of HTTPS, using -p or --proxytunnel flag is recommended. This directs curl to make an HTTP CONNECT request before sending the request. This flag is automatically assumed to be set if the request is HTTPS.

Here is a short summary of these flags:

-x or --proxyProxy URL including scheme, hostname and optional credentials
--proxy-userusername:password
-p or --proxytunnelExplicit TCP tunnel for plain-text requests
Command line flags related to HTTP proxy for curl

It is recommended to use flags with full names (--proxy) rather than short-names (-x) since that makes the script or command a bit more self-explanatory.

Visit this post by Daniel (curl’s BDFL) to learn more about other proxy-related flags: https://daniel.haxx.se/blog/2016/11/26/https-proxy-with-curl/