mac命令终端配置代理

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
复制代码

转载于:https://juejin.im/post/5b892f3451882543094b3b08

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值