没有 公网ip 建站 使用openwrt连接cloudflare隧道实现

By | 2024-02-29

MarkDown

openwrt 使用cloudflare的 隧道 功能 实现没有公网ip搭建web服务 建站自带ssl证书和CDN
另外一个 ,https://www.youtube.com/watch?v=U2LAxqhB8fM
bilibili-B站:https://www.bilibili.com/video/BV1Dk4y1u7h3/
YouTube视频:https://youtu.be/apkpLDlD1Js
openwrt 使用cloudflare的 隧道 功能 实现没有公网ip搭建web服务 建站自带ssl证书和CDN
文本地址:https://d.wanuse.com/a
博客地址:www.wanuse.com
openwrt固件地址:https://d.wanuse.com/openwrt
电报群 : https://t.me/PCDN3

先登录cloudflare官网

在终端输入命令

代码:

cloudflared tunnel login
给出创建连接,进入选择一个域名 授权

授权后 终端提示成功创建证书 并且(cert.pem)已经下载到下面目录

/root/.cloudflared/cert.pem

下面创建隧道

代码:

cloudflared tunnel create wanuse
提示创建成功 /root/.cloudflared/3c4a29c1-e363-4598-854c-12345678.json

复制 /root/.cloudflared/ 下所有文件到 etc/cloudflaed/ 目录

然后去修改配置文件 etc/cloudflaed/config.yml

代码:

url: http://localhost:8000

tunnel: 3c4a29c1-e363-4598-854c-12345678
credentials-file: /etc/cloudflared/3c4a29c1-e363-4598-854c-12345678.json
运行隧道

代码:

cloudflared tunnel run 5e8effbb-a5e0-4436-8a68-12345678
加入启动项 并且后台运行

代码:

nohup cloudflared tunnel run 3c4a29c1-e363-4598-854c-12345678 >/dev/null 2>&1 &

建议结合视频配置