CloudflareTunnel代理访问服务器数据库

153 字
1 分钟
CloudflareTunnel代理访问服务器数据库

起因服务器在国外,ip直连总是遇到各种各样的问题,于是干脆用Cloudflare Tunnel通过域名方式来连接数据库。

# ===== xxx =====
# description: rn135ssh.example.top manual entry
# environment: development
# tags: manual,rn135ssh
# location: 1Panel
# created_at: 2026-03-23 15:15:46
# updated_at: 2026-03-23 15:15:46
Host rn135ssh
HostName rn135ssh.example.top
User root
IdentityFile C:\Users\Root\.ssh\dell
ProxyCommand "C:/Users/Root/AppData/Local/Microsoft/WinGet/Packages/Cloudflare.cloudflared_Microsoft.Winget.Source_8wekyb3d8bbwe/cloudflared.exe" access ssh --hostname %h

去除每次都要输入passphrase验证:

Terminal window
Set-Service ssh-agent -StartupType Automatic
Start-Service ssh-agent
ssh-add C:\Users\Root\.ssh\dell

安装cloudflare:

winget install --id Cloudflare.cloudflared

设置连接:

Terminal window
cloudflared access tcp --hostname db.postgres-xxx.example.top --url 127.0.0.1:15433
2026-03-23T06:37:04Z INF Start Websocket listener host=127.0.0.1:15433

即可localhost:15433访问数据库

image-20260324092640990
image-20260324092640990

踩坑:

  1. 开启了虚拟网卡代理

  2. 罪魁祸首,域名起的太花了=-=

    image-20260324092839714
    image-20260324092839714

文章分享

如果这篇文章对你有帮助,欢迎分享给更多人!

CloudflareTunnel代理访问服务器数据库
https://shaio.top/posts/dev/cloudflaretunnel代理访问服务器数据库/
作者
沙海
发布于
2026-03-23
许可协议
CC BY-NC-SA 4.0

评论区

Profile Image of the Author
沙海
Hello, I'm Shai.
公告
欢迎来到我的博客!这是一则示例公告。
音乐
封面

音乐

暂未播放

0:00 0:00
暂无歌词
分类
标签
站点统计
文章
84
分类
15
标签
48
总字数
67,035
运行时长
0 天
最后活动
0 天前
站点信息
构建平台
GitHub Actions
博客版本
Firefly v6.12.2
文章许可
CC BY-NC-SA 4.0

文章目录