Go 使用代理方法

  • 链接远程服务器,设置SSH端口转发
sudo apt-get install plink
#!/bin/bash
plink -N -v -P 22 user@[ipv6address] -D 127.0.0.1:7070 -pw XXXX
  • 将SOCK5代理转发为HTTP代理(Go不支持SOCKS5代理)
# 安装privoxy
sudo apt-get install privoxy

# 设置privoxy配置文件/etc/privoxy/config
forward-socks5 / 127.0.0.1:7070 . #SOCKS5代理地址
listen-address 127.0.0.1:8118 #HTTP代理地址
forward 192.168.*.*/ . #本地地址不走代理通道
forward 10.*.*.*/ .
forward 127.*.*.*/ .

# 启动privoxy
/etc/init.d/privoxy start
  • 设置http代理(Go不支持SOCKS5代理)
export http_proxy=http://127.0.0.1:8118
export https_proxy=http://127.0.0.1:8118

你可能感兴趣的:(Go 使用代理方法)