Ubuntu – How to make curl use proxy automatically


Today I configured the PC of my company to setup a proxy and it worked because I can wget web page via proxy.

What I did is set http_proxy, https_proxy and ftp_proxy in the ~/.bashrc and in the ~/.wgetrc.

However, when I tried to curl www.google.fr, it blocked and timeout.

curl --proxy $http_proxy www.google.fr worked as expected.

Is it possible to make curl use the proxy automatically?

Best Answer

Perhaps the easiest way to get curl to use a proxy is to add the details into ~/.curlrc file. The syntax is as follows:

proxy = <proxy_host>:<proxy_port>

This can alternatively be set as an environmental variable but IMHO using ~/.curlrc is the most direct and least error prone method.