Total Pageviews

Sunday, 6 October 2019

利用tunnel程序:‘gotunnel-by-liudanking’ + http proxy翻墙

登陆linux vps,首先安装go环境。然后,
cd $GOPATH
go get -u -v github.com/liudanking/gotunnel
(在$GOPATH/bin/里面就会生成可执行文件gotunnel: /root/go/gopath/bin/gotunnel )

注册一个域名yourdomain.com(免费域名也行),添加域名yourdomain.com的a记录,指向你的服务器的公网ip.
然后按此文https://briteming.blogspot.com/2017/06/lets-encryptsslcertbot.html,替你的域名yourdomain.com申请证书。

nano /etc/systemd/system/gotunnel-by-liudanking.service
其内容为:
[Unit]
After=network.target

[Service]
ExecStart=/root/go/gopath/bin/gotunnel -m remote -c /etc/letsencrypt/live/yourdomain.com/fullchain.pem -k /etc/letsencrypt/live/yourdomain.com/privkey.pem -l 0.0.0.0:9001 -r 127.0.0.1:7070

Restart=always

[Install]
WantedBy=multi-user.target

以上的命令/root/go/gopath/bin/gotunnel -m remote -c /etc/letsencrypt/live/yourdomain.com/fullchain.pem -k /etc/letsencrypt/live/yourdomain.com/privkey.pem -l 0.0.0.0:9001 -r 127.0.0.1:7070的意思是gotunnel以服务器模式运行,监听9001端口,收到外部连接9001端口的请求后,转发到vps本机上的7070端口,而vps本机上的7070端口上运行着一个http proxy程序(详见https://briteming.blogspot.com/2019/08/httphttp-proxy.html

然后,运行:
systemctl start gotunnel-by-liudanking
systemctl enable gotunnel-by-liudanking
服务器端搭建完成。

在本地机器mac上。首先安装go环境。然后,
cd $GOPATH
go get -u -v github.com/liudanking/gotunnel
不过运行命令:go get -u -v github.com/liudanking/gotunnel遇错。


cd ~
git clone https://github.com/liudanking/gotunnel gotunnel-by-liudanking
cd gotunnel-by-liudanking
go build .
(会在当前目录下,生成可执行文件gotunnel-by-liudanking)
cat Makefile
显示:
build:
@echo "building..." && \
go build && \
echo "Done!"


run-local: build
./gotunnel -d -m local -l 127.0.0.1:9000 -r tls-local.618033988.cc:9001 -t 1

run-remote: build
./gotunnel -d -m remote -l 127.0.0.1:9001 -r 106.185.47.240:80 -c "/Users/liudanking/Documents/config/ssh-key/ngg/star_cert_combine.pem" -k "/Users/liudanking/Documents/config/ssh-key/ngg/star_618033988_cc.key"

运行:
./gotunnel-by-liudanking -m local -l 127.0.0.1:9000 -r yourdomain.com:9001
保持此terminal不要关闭。

设置你本地机器的浏览器的http proxy为127.0.0.1 ,端口为9000,浏览器即可翻墙。

注意:如果服务器上的7070端口运行的是某个socks proxy,那么本地机器的浏览器的proxy协议需相应的选择socks proxy协议。

不过,用来看youtube,有点慢。
项目地址:github.com/liudanking/gotunnel
---------

利用tunnel程序:‘stunnel-by-liudanking’ + http proxy翻墙 

登陆linux vps,首先安装go环境。然后,
git clone https://github.com/liudanking/stunnel stunnel-by-liudanking
cd stunnel-by-liudanking
go build -o stunnel .
(会在当前目录下,生成可执行文件stunnel)
./stunnel -m remote -c /etc/letsencrypt/live/gt.smt.biz.st/fullchain.pem -k /etc/letsencrypt/live/gt.smt.biz.st/privkey.pem -l 0.0.0.0:8001 -r 127.0.0.1:7070 
可以用systemd把此命令运行为service:
nano /etc/systemd/system/stunnel-by-liudanking.service
其内容为:
[Unit]
After=network.target

[Service]
ExecStart=/root/stunnel-by-liudanking/stunnel -m remote -c /etc/letsencrypt/live/yourdomain.com/fullchain.pem -k /etc/letsencrypt/live/yourdomain.com/privkey.pem -l 0.0.0.0:8001 -r 127.0.0.1:7070

Restart=always

[Install]
WantedBy=multi-user.target

然后,运行:
systemctl start stunnel-by-liudanking
systemctl enable stunnel-by-liudanking
服务器端搭建完成。


在本地机器mac上。首先安装go环境。然后,
git clone https://github.com/liudanking/stunnel stunnel-by-liudanking
cd stunnel-by-liudanking
go build .
(会在当前目录下,生成可执行文件stunnel-by-liudanking)
./stunnel-by-liudanking -m local -l 127.0.0.1:8000 -r yourdomain:8001
保持此terminal不要关闭。

设置你本地机器的浏览器的http proxy为127.0.0.1 ,端口为8000,浏览器即可翻墙。

注意:如果服务器上的7070端口运行的是某个socks proxy,那么本地机器的浏览器的proxy协议需相应的选择socks proxy协议。

不过,用来看youtube,有点慢。
项目地址:https://github.com/liudanking/stunnel
-----------
类似的tunnel程序:
https://briteming.blogspot.com/2015/09/gotunnel.html