skip to content
Liu Yang's Blog
Table of Contents

主要用来隐藏源站IP,并且起到一定的加速的效果。

网页端 / HTTPS

例如,gitea网站为git.example.com

直接在Cloudflare开启小云朵即可,用户无感,但是此时直接通过git clone ssh地址的方式将无效

因此,需要对SSH的使用做额外处理。

对SSH方式的单独处理

  1. 通过Cloudflare Tunnel以内网穿透的方式,将SSH穿透出。

  2. 在CF中,对ssh新增一个主机名,例如git-ssh.example.com,解析为对应的Tunnel CNAME

  3. 除此之外,还需在gitea中增加对SSH_DOMAIN的配置,更改为git-ssh.example.com

  4. 重启Docker容器或者Gitea服务即可

客户端访问(较轻量)

~/.ssh/config中,新增如下配置

Terminal window
Host git-ssh.example.com
ProxyCommand /usr/local/bin/cloudflared access ssh --hostname %h

需要注意的是,用户本地需要安装cloudflared,配置中的cloudflared写成命令的形式,非绝对路径也是ok的。

windows可通过scoop等安装,其他系统安装方法详见

Downloads · Cloudflare Zero Trust docs

或者:https://github.com/cloudflare/cloudflared/releases/latest

此时即可正常链接,还有其他多种方式,但是这样对客户端的要求少一些,体验好一些。

参考内容

Zero Trust GitLab SSH & HTTP · Cloudflare Zero Trust docs

Connect to SSH with client-side cloudflared (legacy) · Cloudflare Zero Trust docs

Configuration Cheat Sheet | Gitea Documentation