socks5 转换为 http 代理(使用privoxy)

安装 privoxy

Mac

brew install privoxy

ubuntu

sudo apt-get install privoxy

配置 privoxy

Mac

vi /usr/local/etc/privoxy/config

Ubuntu

sudo vi /etc/privoxy/config 

注释掉

listen-address  localhost:8118

在最后一行添加

forward-socks5t   /   127.0.0.1:1080 .
listen-address  127.0.0.1:8118

127.0.0.1:1080 为 socks5代理地址及端口
socks5 转换为 http 代理(使用privoxy)_第1张图片

127.0.0.1:8118 为转换为http 代理后的地址及端口,8118如果被占用,修改成自己能用的。

启动 privoxy

Mac

/usr/local/Cellar/privoxy/3.0.26/sbin/privoxy /usr/local/etc/privoxy/config
/usr/local/sbin/privoxy /usr/local/etc/privoxy/config

两个启动方法,看你适合哪个,我用的是上面那个,记得换成自己的版本号!

Ubuntu

sudo service privoxy restart

使用http代理

# http://127.0.0.1:8118 为第2部具体配置的listen-address
export http_proxy='http://127.0.0.1:8118' 
export https_proxy=$http_proxy

配置自定义快捷命令

Mac

vi ~/.bash_profile

Ubuntu

vi ~/.bashrc

如果使用的是zsh 修改

vi ~/.zshrc

添加

alias proxyon="export http_proxy='http://127.0.0.1:8118'; export https_proxy=$http_proxy"
alias proxyoff="unset http_proxy; unset https_proxy"

使配置生效

Mac

source ~/.bash_profile

Ubuntu

source ~/.bashrc

如果使用的zsh

source ~/.zshrc

后续开启代理使用proxyon命令即可,关闭代理使用proxyoff

测试

测试sublime 使用代理成功安装sftp,如下图:

socks5 转换为 http 代理(使用privoxy)_第2张图片

你可能感兴趣的:(Mac工具,socks5,privoxy,http代理,sublime)