mac系统配置socks5转http代理

命令行下,访问一些资源不方便,需要转换一下,办法很多,像privoxy,polipo,proxychains等,今天我们研究privoxy

安装privoxy

brew install privoxy

=> Auto-updated Homebrew!
Updated 2 taps (homebrew/cask and homebrew/services).

==> Installing dependencies for privoxy: pcre
==> Installing privoxy dependency: pcre
==> Downloading https://homebrew.bintray.com/bottles/pcre-8.43.catalina.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/35/3517eab75bf5bdb7798414d0af2aaaaf43edd248abc960b008d89b0a0958d537?__gda__=exp=1584257346~hmac=8
######################################################################## 100.0%
==> Pouring pcre-8.43.catalina.bottle.tar.gz
🍺  /usr/local/Cellar/pcre/8.43: 204 files, 5.5MB
==> Installing privoxy
==> Downloading https://homebrew.bintray.com/bottles/privoxy-3.0.28.catalina.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/27/27fe56112d9fda97417f830b4c17a5066b4389f7831db250a702c91d8df62131?__gda__=exp=1584257358~hmac=a
######################################################################## 100.0%
==> Pouring privoxy-3.0.28.catalina.bottle.tar.gz
==> Caveats
To have launchd start privoxy now and restart at login:
  brew services start privoxy
Or, if you don't want/need a background service you can just run:
  privoxy /usr/local/etc/privoxy/config
==> Summary
🍺  /usr/local/Cellar/privoxy/3.0.28: 98 files, 2MB
==> brew cleanup has not been run in 30 days, running now...
Removing: /Users/rainbird/Library/Logs/Homebrew/mysql-client... (64B)
Removing: /Users/rainbird/Library/Logs/Homebrew/mysql-connector-c... (64B)
Removing: /Users/rainbird/Library/Logs/Homebrew/mysql@5.7... (64B)
Removing: /Users/rainbird/Library/Logs/Homebrew/openssl... (64B)
Pruned 1 symbolic links and 4 directories from /usr/local
==> Caveats
==> privoxy
To have launchd start privoxy now and restart at login:
  brew services start privoxy
Or, if you don't want/need a background service you can just run:
  privoxy /usr/local/etc/privoxy/config

配置 privoxy

vi /usr/local/etc/privoxy/config
找到
listen-address  127.0.0.1:8118
取消注释并添加
forward-socks5 / 127.0.0.1:1080 .

127.0.0.1:1080 socks5代理地址及端口
127.0.0.1:8118 转换后http的地址及端口

运行privoxy

只运行一次
privoxy /usr/local/etc/privoxy/config
以服务方式运行:
brew services start privoxy

bash使用使用http代理

export http_proxy="http://127.0.0.1:8118"
export https_proxy=$http_proxy
curl xxx.com
或者
http_proxy="http://127.0.0.1:8118" curl google.com

其它示例
git使用

#全局设置http或https代理
git config --global http.proxy http://127.0.0.1:8118
git config --global https.proxy http://127.0.0.1:8118
#取消代理:
git config --global --unset http.proxy
git config --global --unset https.proxy
#临时使用,可以使用-c参数:
git -c https.proxy=http://127.0.0.1:8118 clone --depth=1 https://github.com/xxx/xxx

that's all


相关博文

About rainbird

IOS攻城狮
This entry was posted in linux and tagged , , , , , , , , . Bookmark the permalink.

发表评论