linux centos cli all proxy

linux centos 下代理http、https、ftp、all_proxy

全局使用代理:

export http_proxy=http://host:port/

export https_proxy=$http_proxy

export ftp_proxy=$http_proxy

export rsync_proxy=$http_proxy

export all_proxy=$http_proxy

export no_proxy="localhost,127.0.0.1,localaddress,.localdomain.com"

总共有以下参数的全局代理:

http_proxy ftp_proxy https_proxy all_proxy no_proxy

HTTP_PROXY HTTPS_PROXY FTP_PROXY NO_PROXY ALL_PROXY

在使用sudo的时候代理:

添加下面的参数到sudo配置文件:

Defaults env_keep += "http_proxy https_proxy ftp_proxy"

使用wget按需代理:

shell下:cp /etc/wgetrc ~/.wgetrc

取消注释 ~/.wgetrc 中http_proxy、https_proxy、ftp_proxy、use_proxy=off(默认关闭代理)

以后使用wget -Y on可以暂时开启代理。

reference:https://wiki.archlinux.org/index.php/proxy_settings

+update

后来我发现一种更好的方法,按需代理

在你的zsh/bash/fish中添加

alias proxy='http_proxy=username:password@proxy-server:port;'

这种方法简单无副作用,在需要运行的软件前加这个就行,比如

$ proxy curl http://www.google.com

就可以直接访问了

+update2

go get如果timeout,可以直接设置git的代理,因为go get会调用git/svn来代理

git代理,在.gitconfig添加:

[http]

proxy = http://username:password@proxy_server:proxy_port

postBuffer = 24288000

svn代理,在.hgrc添加:

[http_proxy]

host = proxy_server:proxy_port

user = username

passwd = password

如果还提示错误,你要看看是不是go get的那个项目的dep错误,自己打开那个项目看看还寸不存在,然后hg clone一遍。