openwrt 群晖 jellyfin ubuntu 等本地设备映射公网,超简单! 发表评论 / 文章 / 作者: jdssl 无流量限制,速度快配置简单 任意一个可以使用ssh链接的linux 系统中 ,比如本地搭建的ubuntu ,本次用本地同一电脑搭建的pve 搭建了openwrt 群晖 ubuntu ,其中操作在ubuntu中实现局域网所有应用可公网访问。 安装cloudflare tunnelwget https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64.debsudo dpkg -i cloudflared-linux-amd64.deb 然后登录你的 Cloudflare 帐号,下方会出现一个链接,使用这个链接登录自己的cf账号,授权域名。cloudflared tunnel login 创建一个tunnel,一般默认在这里/etc/cloudflared/,如果在root目录下,需要对应修改 下方cd 部分内容cloudflared tunnel create myhome 创建config.yml进入配置目录: cd /etc/cloudflared 新建配置文件: sudo nano config.yml 写入以下内容(按你的IP改): tunnel: <你的Tunnel ID> # 自动生成的ID credentials-file: /etc/cloudflared/<你的Tunnel ID>.json ingress: - hostname: ubuntu.yourdomain.com service: <http://192.168.123.100:5678> # 访问Ubuntu的web服务,比如n8n等 - hostname: nas.yourdomain.com service: <https://192.168.123.101:5001> originRequest: noTLSVerify: true # 群晖自签证书需要跳过验证 - hostname: openwrt.yourdomain.com service: <http://192.168.123.102:80> - service: http_status:404 注意替换 yourdomain.com 成你自己的域名,替换 IP 和端口!保存退出(Ctrl+O 回车,然后 Ctrl+X)。 创建dns解析让Cloudflare后台帮你自动建子域名:需要替换对应的域名cloudflared tunnel route dns myhome ubuntu.yourdomain.comcloudflared tunnel route dns myhome nas.yourdomain.comcloudflared tunnel route dns myhome openwrt.yourdomain.com 开机自启动设置执行: sudo cloudflared service install 然后启动 Tunnel: sudo systemctl enable cloudflared sudo systemctl start cloudflared 查看状态确认: sudo systemctl status cloudflared ✅ 看到绿色 running 就OK了! 如果安装在root 目录下 需要执行 下方命令sudo cp /root/.cloudflared/config.yml /etc/cloudflared/config.ymlsudo systemctl restart cloudflared 重启 reboot 看是否生效。一般需要等待 cloudflaer 解析后 一段时间才能正常使用域名访问本地对应的应用。 阅读量 18 分享到:FacebookX赞过:赞 正在加载……