如何设置curl来永久使用代理?

我如何设置“curl”在terminal中永久使用代理服务器?

你可以在你的〜/ .bashrc文件中创建一个别名:

alias curl="curl -x <proxy_host>:<proxy_port>" 

另一个解决方案是使用(也许更好的解决方案) ~/.curlrc文件(如果它不存在,创建它):

 proxy = <proxy_host>:<proxy_port> 

许多UNIX程序都遵守http_proxy环境变量,包括curl。 curl接受的格式是[protocol://]<host>[:port]

在你的shell配置中:

 export http_proxy http://proxy.server.com:3128 

对于代理HTTP S请求, https_proxy设置https_proxy

Curl也允许你在你的.curlrc文件(Windows上的_curlrc )中设置它,你可能认为这是永久的:

 http_proxy=http://proxy.server.com:3128 

一个通知。 在Windows上,将_curlrc放入'%APPDATA%'或'%USERPROFILE%\ Application Data'中。

Curl将在启动时在您的home文件夹中查找.curlrc文件。 你可以创建(或编辑)这个文件并添加下面的代码:

 proxy = yourproxy.com:8080