1.测试当前环境
curl ip.gs
2.安装polipo
brew install polipo
3.启动
a.启动监听
polipo socksParentProxy=127.0.0.1:1080
b.创建每次系统启动都监听
1.创建启动文件
ln -sfv /usr/local/opt/polipo/*.plist ~/Library/LaunchAgents
2.编辑启动文件设置parentProxy
vim /usr/local/opt/polipo/homebrew.mxcl.polipo.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>homebrew.mxcl.polipo</string>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
<key>ProgramArguments</key>
<array>
<string>/usr/local/opt/polipo/bin/polipo</string>
<string>socksParentProxy=localhost:1080</string>
</array>
<key>SoftResourceLimits</key>
<dict>
<key>NumberOfFiles</key>
<integer>65536</integer>
</dict>
</dict>
</plist>
3.全局配置环境
vim ~/.bash_profile
增加以下代码用来控制代理开启和关闭
# -------------------------------
# polipo proxy on/off
# ------------------------------
function proxy_off() {
launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.polipo.plist
unset http_proxy
}
function proxy_on() {
export http_proxy=http://localhost:8123
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.polipo.plist
}
4.使用
在某个命令终端启动,其他命令终端不受影响
启动: proxy_on
关闭:proxy_off
4.遇到Git配置问题
a.git 移除全局配置代理
git config --global --unset http.proxy
git config --global --unset https.proxy
b.查看信息git配置信息
git config --global -l
c.设置代理
git config --global http.proxy 'socks5://127.0.0.1:1080'
git config --global https.proxy 'socks5://127.0.0.1:1080'
如果配置了全局的git会影响到sourcetree或者其他命令终端的git命令,请小心使用!!!