Tianhe Gao

使用 Cloudflare Tunnel 将本地网页暴露在公网中

记录自己的配置过程。参考文章:Setting up a Cloudflare Tunnel on the Raspberry Pi - Pi My Life Up


树莓派3b闲了很长时间,想把它利用起来。重装了 Ubuntu 22.04 LTS。

所有依次执行的命令:

 1sudo apt update
 2sudo apt upgrade
 3sudo apt install curl lsb-release
 4curl -L https://pkg.cloudflare.com/cloudflare-main.gpg | sudo tee /usr/share/keyrings/cloudflare-archive-keyring.gpg >/dev/null
 5echo "deb [signed-by=/usr/share/keyrings/cloudflare-archive-keyring.gpg] https://pkg.cloudflare.com/cloudflared $(lsb_release -cs) main" | sudo tee  /etc/apt/sources.list.d/cloudflared.list
 6sudo apt update
 7sudo apt install cloudflared
 8cloudflared tunnel login # 点击出现的链接,选择域名
 9cloudflared tunnel create TUNNELNAME
10cloudflared tunnel route dns TUNNELNAME DOMAINNAME
11cloudflared tunnel run --url localhost:PORT TUNNELNAME

设置 systemd 服务,使得开机自启:

1sudo vim ~/.cloudflared/config.yml
2sudo cloudflared --config ~/.cloudflared/config.yml service install
3sudo systemctl enable cloudflared
4sudo systemctl start cloudflared

~/.cloudflared/config.yml:

1tunnel: [TUNNELNAME]
2credentials-file: /home/[USERNAME]/.cloudflared/[UUID].json
3
4ingress:
5    - hostname: [HOSTNAME]
6      service: [PROTOCOL]://localhost:[PORT]
7    - service: http_status:404

No notes link to this note

Welcome to tell me your thoughts via "email"
UP