Bootstrap FreeKB - Curl - Use a proxy server
Curl - Use a proxy server

Updated:   |  Curl articles

The curl command with the -x or --proxy option can be used to first forward the request onto a proxy server, and then the proxy server would forward the request onto the target server. In this example, the request is first sent to the proxy server at http://proxy.example.com.

curl --proxy http://proxy.example.com:80 www.example.com

 

If the proxy server requires basic authentication (username / password), and a valid username and password are not included in the request, something like this should be returned.

~]$ curl --proxy http://proxy.example.com:80 www.example.com
<title>407 Proxy Authentication Required</title>
</head><body>
<h1>Proxy Authentication Required</h1>
<p>This server could not verify that you
are authorized to access the document
requested.  Either you supplied the wrong
credentials (e.g., bad password), or your
browser doesn't understand how to supply
the credentials required.</p><p></p>
</body></html>

 

Here is how you would include the username and password for the proxy server.

curl --proxy http://john.doe:itsasecret@proxy.example.com www.example.com

 

Or like this, using the --proxy-user option.

curl --proxy http://proxy.example.com:80 --proxy-user john.doe:itsasecret www.example.com

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter f68eb8 in the box below so that we can be sure you are a human.