带有代理的 Ubuntu 12.10 cURL

ted*_*ted 5 12.04 curl

我正在使用代理,除了 cURL 之外没有任何问题。

任何时候我尝试做:

curl -L http://link.to.something
Run Code Online (Sandbox Code Playgroud)

我收到:

curl: (5) Couldn't resolve proxy 'http'
Run Code Online (Sandbox Code Playgroud)

尽管如此:

curl --proxy http://myproxy.com:8080 -L http://link.to.something
Run Code Online (Sandbox Code Playgroud)

会很好用。

有没有办法--proxy每次都不写?

hhl*_*hlp 5

从男人卷曲:

-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.
Run Code Online (Sandbox Code Playgroud)

一般用途,为http/https声明环境变量

export http_proxy=http://your.proxy.server:port/
export https_proxy=$http_proxy
Run Code Online (Sandbox Code Playgroud)
  1. 编辑 /etc/bash.bashrc 添加到文件末尾:
    export http_proxy=http://username:password@proxyserver.com:port/
    export https_proxy=$http_proxy
    export ftp_proxy=http://username:password@proxyserver.com:port/
Run Code Online (Sandbox Code Playgroud)
  • 或代理没有用户名和密码的情况 - :
    export http_proxy=http://proxyserver.com:port/
    export https_proxy=$http_proxy
    export ftp_proxy=http://proxyserver.com:port/
Run Code Online (Sandbox Code Playgroud)