下载
1
| curl -L 'https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64' -o /usr/local/bin/cloudflared
|
- 登录认证
1
| cloudflared tunnel login
|
- 创建域名,得到隧道ID
1
| cloudflared tunnel route dns ssh awssgssh.543083.xyz
|
- 修改配置文件,添加 SSH 代理
1
2
3
4
5
6
7
8
9
10
11
| cat > /root/.cloudflared/config.yml << EOF
tunnel: e7425241-3827-4e3a-830e-dde066ae6915
credentials-file: /root/.cloudflared/e7425241-3827-4e3a-830e-dde066ae6915.json
protocol: h2mux
ingress:
# 第五个,反代 SSH 服务
- hostname: awssgssh.543083.xyz
service: ssh://localhost:1522
# 最后记得添加一个默认 404
- service: http_status:404
EOF
|
- 验证
1
2
| cloudflared tunnel ingress validate
cloudflared tunnel ingress rule https://awssgssh.543083.xyz
|
- 启动测试
1
| cloudflared tunnel --config ~/.cloudflared/config.yml run e7425241-3827-4e3a-830e-dde066ae6915
|
- 安装系统服务
1
| cloudflared --config /root/.cloudflared/config.yml service install
|
- 配置页面 application
参考:使用 Cloudflare Tunnels 通过 Web SSH 访问服务器
参考:https://blog.hellowood.dev/posts/%E4%BD%BF%E7%94%A8cloudflare-tunnels%E9%80%9A%E8%BF%87web-ssh%E8%AE%BF%E9%97%AE%E6%9C%8D%E5%8A%A1%E5%99%A8/
Photo by Pawel Czerwinski on Unsplash