通常使用代理有兩種比較簡單的方式。html
在有公網的服務器上搭建 squid 的代理,最好限制限制訪問來源和只監聽在指定網段的地址上,防止被別人利用。服務器
不建議使用環境變量方式設置代理 "export http_proxy=http://xxx:xxx",這種方式可能會影響其餘程序的使用。curl
# wget ## 命令行方式 wget -e "http_proxy=http://127.0.0.1:8087" http://www.subversion.org.cn/svnbook/1.4/ ## 配置文件方式 ### 將/etc/wgetrc中與proxy有關的幾行復制到~/.wgetrc,並作以下修改 http_proxy = http://127.0.0.1:8087/ ftp_proxy = http://127.0.0.1:8087/ # 是否開啓代理, off or on use_proxy = on # yum ## 在 /etc/yum.conf添加 "proxy=http://ip:port" # curl curl -x "http://xxx:xxx" url # apt-get apt-get -o Acquire::http::proxy="http://127.0.0.1:8000/" update