Table of Contents

Installing and Configuring Cloudflared on an LXC

1. Download and Install Cloudflared

wget https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64.deb
sudo dpkg -i cloudflared-linux-amd64.deb
cloudflared --version

2. Authenticate Cloudflared with Cloudflare

cloudflared tunnel login

3. Create a New Tunnel

cloudflared tunnel create my-tunnel

4. Configure the Tunnel to Route Traffic

sudo nano /etc/cloudflared/config.yml
tunnel: 72a29ddd==== TUNNEL ====cc4d8e3fc2ba
credentials-file: /home/facundo/.cloudflared/72a29ddd-7ef4-46e3-97ef-cc4d8e3fc2ba.json

ingress:
    - hostname: *.facundoitest.space
      service: http://192.168.88.250:443
    - service: http_status:404

5. Run the Tunnel

sudo cloudflared tunnel run my-tunnel

6. Configure NGINX on Raspberry Pi

7. Set Up Cloudflared as a Systemd Service

sudo nano /etc/systemd/system/cloudflared.service
[Unit]
Description=Cloudflare Tunnel
After=network.target

[Service]
Type=simple
User=facundo
ExecStart=/usr/local/bin/cloudflared tunnel run my-tunnel
Restart=on-failure
RestartSec=5s

[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl enable cloudflared
sudo systemctl start cloudflared
sudo systemctl status cloudflared

8. Verify Tunnel Operation

Conclusion

Following these steps will ensure that your `cloudflared` tunnel is correctly set up on your LXC and that it integrates smoothly with your existing reverse proxy setup on your Raspberry Pi.