使用gost搭建隧道

作者:matrix 被围观: 1,004 次 发布时间:2022-12-31 分类:零零星星 | 无评论 »

这是一个创建于 479 天前的主题,其中的信息可能已经有所发展或是发生改变。

很多时候需要搭建简单的socket代理或者其他中转隧道,方便学习开发。
gost是用golang实现的隧道代理工具,功能强大,也有docker环境可以快速使用。

github

https://github.com/go-gost/gost

docker镜像

ginuerzh/gost
gogost/gost

两个docker镜像应该都可信,来源于作者/官方

前置条件

外网服务器 + 中转服务器(可选) + 域名 + 域名SSL证书

下面用中转/直连方案实现隧道代理,记录下~

服务端(outside server)

外网落地服务器

a. 直连方案配置

$   docker run --rm -it \
    --net=host \
    -v /etc/letsencrypt:/etc/letsencrypt:ro \
    ginuerzh/gost -L "mwss://USERNAME:PASSWORD@:443?cert=/etc/letsencrypt/live/wwww.hhtjim.com/fullchain.pem&key=/etc/letsencrypt/live/wwww.hhtjim.com/privkey.pem"

b. 中转方案配置

$   docker run --rm -it \
    --net=host \
    -v /etc/letsencrypt:/etc/letsencrypt:ro \
    ginuerzh/gost -L "relay+mwss://USERNAME:PASSWORD@:443?cert=/etc/letsencrypt/live/wwww.hhtjim.com/fullchain.pem&key=/etc/letsencrypt/live/wwww.hhtjim.com/privkey.pem"

说明:

用户名和密码
USERNAME:PASSWORD

SSL证书
/etc/letsencrypt/live/wwww.hhtjim.com/fullchain.pem
/etc/letsencrypt/live/wwww.hhtjim.com/privkey.pem

中转服务端(inside server)

inside中转服务器,仅b.中转方案需要

目的:将服务端的relay+mwss中转为ss协议

$  docker run -p 8081:8081 -it -d  --name gost-client gogost/gost -L ss://aes-256-cfb:PASSWORD2@:8081  -F "relay+mwss://USERNAME:PASSWORD@wwww.hhtjim.com:443"

说明:

8081为中转服务器本地启用的隧道端口

本地客户端

a. 直连方案

$  docker run -p 9898:9898 --rm gogost/gost -L ":9898" -F "mwss://USERNAME:PASSWORD@wwww.hhtjim.com:443"

说明:
9898为转发到本地的socket5端口
本地连接socket5://127.0.0.1:9898即可

b. 中转方案

普通客户端直连国内中转ip的ss协议
按照自己配置的中转方案参数,连接ss即可

测试

$ curl --proxy http://127.0.0.1:9898 -X GET 'https://ipinfo.io'

$ curl -v "https://www.google.com" --proxy "http://127.0.0.1:9898"

参考:

https://latest.gost.run/

https://v2.gost.run/port-forwarding/

https://github.com/haoel/haoel.github.io

https://ednovas.xyz/2021/02/24/mtproxy/#gost%E4%B8%AD%E8%BD%AC

https://telegra.ph/socks5%E5%8F%8AMTProto%E4%BB%A3%E7%90%86%E8%AE%BE%E7%BD%AE%E8%84%9A%E6%9C%AC-05-31

其他文章:
本文固定链接:https://www.hhtjim.com/use-gost-to-build-the-tunnel.html
matrix
本文章由 matrix 于2022年12月31日发布在零零星星分类下,目前没有通告,你可以至底部留下评论。
转载请注明:使用gost搭建隧道-HHTjim'S 部落格
关键字:, ,

添加新评论 »

 🙈 😱 😂 😛 😭 😳 😀 😆 👿 😉 😯 😮 😕 😎 😐 😥 😡 😈 💡

插入图片

NOTICE: You should type some Chinese word (like “你好”) in your comment to pass the spam-check, thanks for your patience!