Monday, May 19, 2025

Seamless File Sync: Raspberry Pi Windows 11 Android with Syncthing

Here’s the full installation guide for Raspberry Pi + Windows 11 + Android Syncthing, perfect for blogging, tech notes, or internal documentation:
Overview
Syncthing is a powerful, open-source, peer-to-peer file synchronization tool that allows you to automatically sync photos, documents, and videos across your devices—without any cloud, no public IP required, and with full control over your data.

Step 1: Install Syncthing on Raspberry Pi
Supported System: Raspberry Pi OS (Raspbian 12)
Installation Script:

# Add Syncthing repository and key
curl -s https://syncthing.net/release-key.txt | sudo gpg –dearmor -o /usr/share/keyrings/syncthing-archive-keyring.gpg

echo ”deb [signed-by=/usr/share/keyrings/syncthing-archive-keyring.gpg] https://apt.syncthing.net/ syncthing stable” | 
sudo tee /etc/apt/sources.list.d/syncthing.list

# Update and install
sudo apt update
sudo apt install syncthing -y

Enable Syncthing at boot:

sudo systemctl enable syncthing@pi
sudo systemctl start syncthing@pi

Replace pi with your actual username if different.

Step 2: Install Syncthing on Windows 11
Download from: syncthing

After launching, Syncthing will open the web interface at http://127.0.0.1:8384

Tips:

Set sync folder to a dedicated path like D:Syncthing

Enable “Start Syncthing automatically”

Allow firewall access on private networks
Step 3: Install Syncthing on Android
Recommended app: Syncthing-Fork (more stable and full-featured)

Available on Google Play
or
F-Droid

Auto-backup camera photos:
Add folder: /storage/emulated/0/DCIM/Camera

Set folder type: Send Only

Connect to other devices as receivers

Step 4: Connect All Devices
Each device has a Device ID. You need to:

1.Share Device IDs across devices and accept connection requests

2.Add shared folders with identical Folder IDs

3.Set folder paths on each device:

Raspberry Pi: /home/pi/sync/photos

Windows: D:Syncthingphotos

Android: /storage/emulated/0/Syncthing/photos

Make sure Folder IDs are exactly the same across all devices to sync correctly.

Optional: Enable Remote Access to Raspberry Pi’s Syncthing Web UI

nano ~/.config/syncthing/config.xml

Modify this section:

<gui>
  <address>0.0.0.0:8384</address>
  <user>yourusername</user>
  <password>yourpassword</password>
</gui>

Restart the service:

systemctl restart syncthing@pi

You can now access it from LAN:

http://<raspberry-pi-local-ip>:8384

Use Cases
Photo backup: Android → Raspberry Pi → Windows

Document sync: Windows ↔ Raspberry Pi

Media sharing: Download on Raspberry Pi → Sync to Android

Pi backups: Automatically mirror SD card contents

Bonus: Syncthing Tips
Use “Send Only” for backup folders (e.g., Camera)

Use “Receive Only” to prevent changes from propagating

Run Syncthing as a background service on Raspberry Pi and Windows

Enable “Ignore Permissions” on Android if sync fails

Sunday, May 18, 2025

Cloudflare Tunnel Setup(Full Flow)

Here’s a clean and concise English guide for setting up Cloudflare Tunnel (cloudflared) to expose your NAS or local service via a subdomain — using the full CLI workflow.
1. Install cloudflared
Download the correct version for your system (e.g., ARM for Raspberry Pi):

wget https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-arm -O cloudflared
chmod +x cloudflared
sudo mv cloudflared /usr/local/bin/

Test it:

cloudflared –version

2. Login to Cloudflare
cloudflared tunnel create my-nas
A browser tab will open. Log into your Cloudflare account and select your domain.
3. Create a Tunnel

cloudflared tunnel create my-nas

This generates:

A unique tunnel-id

A credentials JSON file (usually saved to /root/.cloudflared/xxxxxxxx-xxxx.json)
4. Configure the Tunnel
Create the config file:

sudo nano /root/.cloudflared/config.yml

Example config:

tunnel: YOUR_TUNNEL_ID
credentials-file: /root/.cloudflared/YOUR_TUNNEL_ID.json

ingress:
  - hostname: nas.yourdomain.com
    service: http://localhost:80
  - service: http_status:404

Replace:

YOUR_TUNNEL_ID with the actual tunnel ID (get it from cloudflared tunnel list)

nas.yourdomain.com with your real subdomain

Step 5 – Configure DNS on Cloudflare
After creating your tunnel, you need to link a subdomain to it via Cloudflare DNS.

You have two options:

✅ Option A: Automatically via cloudflared command

cloudflared tunnel route dns my-nas nas.yourdomain.com

Cloudflare will automatically:

Add a CNAME record to your DNS

Point it to the correct cfargotunnel.com domain

Enable proxying (orange cloud ☁️)

🛠️ Option B: Manually via Cloudflare Dashboard
Go to your Cloudflare DNS settings, and add the following record:

::: tip Cloudflare DNS Record
📌 **Type:** CNAME  
🔖 **Name:** nas  
🌐 **Target:** `<tunnel-id>.cfargotunnel.com`  
☁️ **Proxy:** Enabled (Proxied ✅)
:::

📝 Replace with your actual tunnel ID (from cloudflared tunnel list).

Example:

CNAME  nas  123abc456def7890.cfargotunnel.com  Proxied ✅

6. Install as System Service

sudo cloudflared service install

This installs the tunnel as a systemd service and enables it to start on boot.
7. Start & Check Status

sudo systemctl start cloudflared
sudo systemctl status cloudflared

Logs:

journalctl -u cloudflared -f

Test It
Visit: https://nas.yourdomain.com

Ensure your local NAS service is running (e.g., Nginx/HTTPS enabled)

Port 80/443 must be listening internally, but no port-forwarding is needed.