echo 'deb [signed-by=/usr/share/keyrings/cloudflare-main.gpg] https://pkg.cloudflare.com/cloudflared any main' | sudo tee /etc/apt/sources.list.d/cloudflared.list
sudo cloudflared service install eyJhIjoiODViZjQwNTNlOGUyZDNWRhMWU1MjM5IiwicyI6xxxIk16UTBNV0UzWXpRdE1tSmtaaTAwWTJKakxXSXlNRFV0WlRKbVlXTmhNalEwTkRkbSJ9
成功连接之后,重新刷新一下,cloudflare的网站
点击管理隧道
点击查看隧道
就可以查看到隧道而连接情况了
内网穿透
以内网搭建的Halo网站为例
点击隧道配置的按钮
点击选择公共主机名
点击添加公共主机名
服务填入内网搭建的服务,这里输入nw的三级域名(可以不填写)
设置完成之后,验证内网穿透的结果。
成功访问内网搭建的服务。
常见的错误
出现连接的报错信息
1 2 3
2025-04-12T12:21:13Z INF Using Systemd 2025-04-12T12:21:13Z ERR error generating service template error="cloudflared service is already installed at /etc/systemd/system/cloudflared.service; if you are running a cloudflared tunnel, you can point it to multiple origins, avoiding the need to run more than one cloudflared service in the same machine; otherwise if you are really sure, you can do `cloudflared service uninstall` to clean up the existing service and then try again this command" cloudflared service is already installed at /etc/systemd/system/cloudflared.service; if you are running a cloudflared tunnel, you can point it to multiple origins, avoiding the need to run more than one cloudflared service in the same machine; otherwise if you are really sure, you can do `cloudflared service uninstall` to clean up the existing service and then try again this command
输入如下命令进行卸载
1 2 3
web@ubuntu:~/Desktop$ sudo cloudflared service uninstall 2025-04-12T12:23:14Z INF Using Systemd 2025-04-12T12:23:15Z INF Linux service for cloudflared uninstalled successfully
卸载完成之后,在重新连接
1
sudo cloudflared service install eyJhIjoiODViZjQwNTNlOGUyZDNWRhMWU1MjM5IiwicyI6xxxIk16UTBNV0UzWXpRdE1tSmtaaTAwWTJKakxXSXlNRFV0WlRKbVlXTmhNalEwTkRkbSJ9