Total Pageviews

Wednesday 1 April 2020

使用https程序:'gtunnel+http proxy'翻墙

linux vps上。首先安装go环境。然后,
cd $GOPATH
go get -u -v github.com/fangdingjun/gtunnel/

cd ~
wget https://raw.githubusercontent.com/fangdingjun/gtunnel/master/config_example.yaml -gtunnel-config.yaml
nano gtunnel-config.yaml
cat gtunnel-config.yaml
# gtunnel can do the follow things
#  a. listen plain, forward through TLS
#  b. listen plain, forward through plain
#  c. listen TLS, forward through plain
#  d. listen TLS, forward through TLS
#
# when cert and key specified it will listen on TLS
#

-
    # listen tls and forward through plain
    listen:
        host: 0.0.0.0
        port: 4430
        cert: /root/.acme.sh/xyz.com/fullchain.cer
        key: /root/.acme.sh/xyz.com/xyz.com.key
        hostname: xyz.com

    backend:
        host: localhost
        port: 7070
        tls: false

此处的xyz.com是你的域名,请把它解析到你的服务器的ip. 7070端口是你的服务器上安装的某个http proxy程序,比如tinyproxy监听的端口号。此处的配置文件的意思是你访问主机xyz.com:4430,你的服务器会把此访问请求转发到后端的某个http proxy,再由此http proxy去访问目标网站/被封的网站。

然后,运行:
gtunnel -c ~/gtunnel-config.yaml
不过gtunnel -c ~/gtunnel-config.yaml是运行在前台的,我们可以使用systemd把它运行为service:
nano /etc/systemd/system/gtunnel.service
cat /etc/systemd/system/gtunnel.service
[Unit]
After=network.target

[Service]
ExecStart=/root/go1.13/go/gopath/bin/gtunnel -c /root/gtunnel-config.yaml
Restart=always

[Install]
WantedBy=multi-user.target

然后运行:
systemctl start gtunnel
systemctl enable gtunnel

服务器端搭建完成。

在本地机器的chrome上,安装switchy-omega插件,然后新建一个情景模式,代理协议选择https,代理服务器地址填你的域名xyz.com, 代理端口填4430,点击“应用选项”,选择此情景模式,即可用chrome翻墙。

https程序再次添加一员。

项目地址:

相关帖子:

---------------------------------

tlsendpoint

a tls termination util that forward the request to backend server by sni name
support many different kind of backends, tcp, unix, tls...
example:
client A requests with sni name a.example.com forward to 127.0.0.1:8081
client B requests with sni name b.example.com forward to 127.0.0.1:8082
usage
go get github.com/fangdingjun/tlsendpoint
cp $GOPATH/src/github.com/fangdingjun/tlsendpoint/config_example.yaml config.yaml
vim config.yaml
$GOPATH/bin/tlsendpoint -c config.yaml
frm https://github.com/fangdingjun/tlsendpoint