Bash终端命令行,使用privoxy将socks代理转成http代理
安装privoxy
# Ubuntu/debian sudo apt-get install privoxy # Centos sudo yum install privoxy # Mac osx sudo port install privoxy
修改配置文件
vi /etc/privoxy/config
# HTTP parent looks like this:
#
forward-socks4 / 127.0.0.1:1080 .
#
# To chain Privoxy and Tor, both running on the same system, you
# would use something like:
#
forward-socks5 / 127.0.0.1:1080 .主要是forward-socks 这两行,1080是socks代理开启的端口,根据自己实际情况修改
配置完成后,重启privoxy,sudo service privoxy restart
添加代理开关函数
vi ~/.bashrc,添加如下代码:
function proxy_off(){
unset http_proxy
unset https_proxy
unset ftp_proxy
unset rsync_proxy
echo -e "已关闭代理"
}
function proxy_on() {
export no_proxy="localhost,127.0.0.1,localaddress,.localdomain.com"
export http_proxy="http://127.0.0.1:8118"
export https_proxy=$http_proxy
export ftp_proxy=$http_proxy
export rsync_proxy=$http_proxy
export HTTP_PROXY=$http_proxy
export HTTPS_PROXY=$http_proxy
export FTP_PROXY=$http_proxy
export RSYNC_PROXY=$http_proxy
echo -e "已开启代理"
}使用的时候,需要开启http代理时,就在命令行输入:proxy_on

此种情况多数用于命令行需要链接的服务器,被墙需要扶梯子时,比如下载android源码,chromium源码 …
推荐一个扶梯子的站点:http://t.cn/RtKobrk
相关推荐
haitianisgood 2020-07-21
吹云 2020-11-05
84407805 2020-11-01
曾是土木人 2020-10-31
java0 2020-09-29
81437716 2020-09-18
81437716 2020-09-13
bluecarrot 2020-09-11
myCat 2020-09-09
83427718 2020-09-07
85560694 2020-09-03
89520991 2020-08-21
89550191 2020-08-09
katie000 2020-08-04
hunningtu 2020-07-30
89961330 2020-07-28
yuzhongdelei0 2020-07-28