在linux vps上。首先安装go环境,然后,
cd $GOPATH
cd $GOPATH
go get -u -v github.com/buraksezer/gsocks5/
gsocks5 -h
mkdir /etc/gsocks5/
cd /etc/gsocks5/
wget https://github.com/buraksezer/gsocks5/raw/master/data/server.json
nano server.json
cat server.json
{
"debug": true,
"server_cert": "cert.pem",
"server_key": "key.pem",
"server_addr":"0.0.0.0:8288",
"password":"yourpassword",
"graceful_period": 1,
"role": "server"
}
配置文件中的cert.pem和key.pem还未生成,我们运行如下命令来生成它们:
openssl req -new -x509 -days 3650 -nodes -out cert.pem -keyout key.pem
然后,
gsocks5 -c /etc/gsocks5/server.json
会显示:
2020/04/10 01:16:16 [INF] gsocks5: Running as server
2020/04/10 01:16:16 [INF] gsocks5: TLS server runs on 0.0.0.0:8288
此命令是运行在前台的,我们可以使用systemd把它运行为service:
nano /etc/systemd/system/gsocks5.service
cat /etc/systemd/system/gsocks5.service
[Unit]
After=network.target
[Service]
WorkingDirectory=/etc/gsocks5/
ExecStart=/root/go1.13/go/gopath/bin/gsocks5 -c /etc/gsocks5/server.json
Restart=always
[Install]
WantedBy=multi-user.target
然后运行:
systemctl start gsocks5
systemctl enable gsocks5
服务器端搭建完成。
在客户机器mac上。首先安装go环境,然后,
cd $GOPATH
go get -u -v github.com/buraksezer/gsocks5/
gsocks5 -h
sudo mkdir /etc/gsocks5/
cd /etc/gsocks5/
sudo wget https://github.com/buraksezer/gsocks5/raw/master/data/client.json
sudo nano client.json
cat client.json
{
"debug": true,
"insecure_skip_verify": true,
"server_addr":"vps-pubic-ip:8288",
"client_addr": "localhost:10800",
"password":"yourpassword",
"dial_timeout": 10,
"keepalive_period": 3600,
"graceful_period": 1,
"role": "client"
}
cd ~
gsocks5 -c /etc/gsocks5/client.json
会显示:
2020/04/10 02:14:29 [INF] gsocks5: Running as client
2020/04/10 02:14:29 [INF] gsocks5: Proxy client runs on localhost:10800
保持此terminal窗口开着。然后设置chrome的socks5 proxy server为127.0.0.1 ,端口为10800,chrome即可翻墙。