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
unset https_proxy
git config --global --unset http.proxy
git config --global --unset https.proxy
}
function proxy_on() {
export http_proxy=http://localhost:8123
export https_proxy=https://localhost:8123
git config --global http.proxy 'socks5://127.0.0.1:1080'
git config --global https.proxy 'socks5://127.0.0.1:1080'
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命令,请使用移除git全局命令先移除代理配置!!!
mac下载webrtc遇到问题: NOTICE: You have PROXY values set in your environment, but gsutil in depot_tools does not (yet) obey them. Also, --no_auth prevents the normal BOTO_CONFIG environment variable from being used. To use a proxy in this situation, please supply those settings in a .boto file pointed to by the NO_AUTH_BOTO_CONFIG environment var. 解决方案:
1.在depot_tools文件夹下创建https_proxy.boto文件,文件内容
[Boto]
proxy = localhost
proxy_port = 8123
复制代码
2.配置环境变量在.bash_profile
export NO_AUTH_BOTO_CONFIG=/Users/Crassus/Desktop/project/YST/WebRTCSource/depot_tools/https_proxy.boto
复制代码