我有这个代理地址:125.119.175.48:8909

如何使用cURL(如cURL http://www.example.com)执行HTTP请求,但指定我的网络的代理地址?


当前回答

旋度vv -ksL“https://example.com”- x " http:// <代理>:< >港”

其他回答

根据您的工作场所,您可能还需要为curl指定-k或——insecure选项,以解决CA证书的潜在问题。

curl -x <myCompanyProxy>:<port> -k -O -L <link to file to download>

来自man curl:

-x, --proxy <[protocol://][user:password@]proxyhost[:port]>

     Use the specified HTTP proxy. 
     If the port number is not specified, it is assumed at port 1080.
sudo curl -x http://10.1.1.50:8080/ -fsSL https://download.docker.com/linux/ubuntu/gpg

这对我来说很完美,错误来了,因为旋度需要设置 代理 记得把代理替换成你的代理,我的代理,“例子”是 http://10.1.1.50:8080。

作为airween的补充,另一个好主意是将它添加到你的.bashrc中,这样你就可以从非代理环境切换到代理环境:

alias proxyon="export http_proxy='http://YOURPROXY:YOURPORT';export https_proxy='http://YOURPROXY:YOURPORT'"
alias proxyoff="export http_proxy='';export https_proxy=''"

WHERE YOURPROXY:YOURPORT就是你的ip和端口代理:-)。

然后,简单地做

proxyon

您的系统将开始使用代理,与之相反:

proxyoff

注意,如果你正在使用SOCKS代理,而不是HTTP/HTTPS代理,你将需要使用——socks5开关:

curl --socks5 125.119.175.48:8909 http://example.com/

还可以使用——socks5-hostname代替——socks5在代理端解析DNS。