Running Cloudflare Argo Tunnel at Alpine Linux
·219 字
1.Download bin file #
curl -L https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64 -o /usr/bin/cloudflared
chmod +x /usr/bin/cloudflared
test:
Crazy:~# cloudflared -V
cloudflared version 2023.10.0 (built 2023-10-31-1234 UTC)
2.Login to Cloudflare #
cloudflared tunnel login
3.Create Tunnel #
cloudflared tunnel create <name>
4.Bind domain #
cloudflared tunnel route dns <name> <hostname>
5.Test Tunnel #
cloudflared tunnel --url ip:port
Crazy:~# cloudflared tunnel --url 127.0.0.1:3001
2023-11-07T04:58:31Z INF Thank you for trying Cloudflare Tunnel...
...
2023-11-07T04:58:33Z INF Registered tunnel connection connIndex=0 connection=deca1c64-f363-4baf-80c8-5f84ac220e71 event=0 ip=198.41.192.77 location=nrt08 protocol=quic
Test:
root@Crazy:~# curl -v https://logitech-clara-controlling-my.trycloudflare.com/
* Trying 104.17.124.55:443...
* Connected to logitech-clara-controlling-my.trycloudflare.com (104.17.124.55) port 443 (#0)
...
* Connection #0 to host logitech-clara-controlling-my.trycloudflare.com left intact
OK.
6.Create config file #
/root/.cloudflared/config.yaml
url: http://localhost:3001
tunnel: b133ae29-3f9e-47af-92c8-3c5d21da3f56
credentials-file: /root/.cloudflared/b133ae29-3f9e-47af-92c8-3c5d21da3f56.json
7.Run as a service #
cloudflared service install
Crazy:~# cloudflared service install
2023-11-07T04:28:04Z INF Using SysV
2023-11-07T04:28:04Z INF Linux service for cloudflared installed successfully
Crazy:~# /etc/init.d/cloudflared status
Running
8.Use IPv6 to connect to CF edge #
add --edge-ip-version 6
to /etc/init.d/cloudflared
.
#!/bin/sh
# For RedHat and cousins:
# chkconfig: 2345 99 01
# description: cloudflared
# processname: /usr/bin/cloudflared
### BEGIN INIT INFO
# Provides: /usr/bin/cloudflared
# Required-Start:
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: cloudflared
# Description: cloudflared agent
### END INIT INFO
name=$(basename $(readlink -f $0))
cmd="/usr/bin/cloudflared --edge-ip-version 6 --pidfile /var/run/$name.pid --autoupdate-freq 24h0m0s --config /etc/cloudflared/config.yml tunnel run"
pid_file="/var/run/$name.pid"
stdout_log="/var/log/$name.log"
stderr_log="/var/log/$name.err"
参考资料: