Mac配置Privoxy设置go get代理

安装Privoxy

地址:https://www.privoxy.org/sf-download-mirror/

配置Privoxy

1
2
3
4
5
cd /Applications/Privoxy
# 监听8118端口
echo 'listen-address 0.0.0.0:8118' >> /usr/local/etc/privoxy/config
# 设置转发socks5服务器
echo 'forward-socks5 / localhost:1080 .' >> /usr/local/etc/privoxy/config

发现提示错误:

1
-bash: /usr/local/etc/privoxy/config: Permission denied

解决方法:

1
2
# 修改/usr/local目录的所有者与组
sudo chown -R "$USER":admin /usr/local

配置HTTP代理

1
2
3
4
5
6
7
8
9
10
11
# 如果你使用bash
vim ~/.bashrc
# 如果你使用zsh
vim ~/.zshrc
# 加入
export http_proxy=http://127.0.0.1:8118/
# 保存退出
# source 使其即刻生效
source ~/.bashrc
# or
source ~/.zshrc

测试Privoxy

1
2
3
4
5
6
7
lawtech@lawdeMacBook-Pro:/Applications/Privoxy$ curl www.google.com
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>302 Moved</TITLE></HEAD><BODY>
<H1>302 Moved</H1>
The document has moved
<A HREF="http://www.google.co.jp/?gfe_rd=cr&amp;dcr=0&amp;ei=G5flWZmXKa_o8Ae9j7PADw">here</A>.
</BODY></HTML>

终于可以开心地go get了!

🐶 ~怕是要给老板下跪了哦~ 🐶