使用privoxy让iterm走ss代理

主要参考使用 shadowsocks 加速 Mac 自带终端或iTerm 2

shadowsocks-NG自带privoxy

Privoxy配置

vim /usr/local/etc/privoxy/config中添加

1
2
listen-address 0.0.0.0:1087 #全局域网可访问
forward-socks5 / localhost:1080 . #最后有个.

然后sudo privoxy /usr/local/privoxy/config

mac段查看端口lsof -iTCP:1087

使用ShadowsocksX-NG

HTTP Proxy Preference选端口

Terminal端

1
2
export http_proxy='http://localhost:1087'
export https_proxy='http://localhost:1087'

取消代理

1
2
unset http_proxy
unset https_proxy

或者在.zshrc中添加开关函数

1
2
3
4
5
6
7
8
9
10
11
function proxy_off(){
unset http_proxy
unset https_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
echo -e "已开启代理"
}

测试当前终端标签/窗口是否走代理:

1
curl ip.gs