# Syncthing File Synchronization

> Continuous file synchronization between devices with encryption and web UI.

- Category: Storage & Backup
- Difficulty: beginner
- Components: syncthing, nginx
- Tags: syncthing, sync, files, p2p, encryption
- Source: https://docker.recipes/storage/syncthing-file-sync

## Overview

Syncthing is a continuous file synchronization program that synchronizes files between two or more computers in real time using peer-to-peer technology, eliminating the need for cloud storage services or central servers. Originally developed in 2013 as an open-source alternative to proprietary sync solutions, Syncthing encrypts all data end-to-end and operates entirely on your own devices, making it ideal for privacy-conscious users and organizations with strict data sovereignty requirements. This deployment combines Syncthing with NGINX to create a robust file synchronization platform where NGINX acts as a reverse proxy, providing SSL termination, rate limiting, and enhanced security for the Syncthing web interface. The NGINX proxy enables secure remote access to Syncthing's management interface while protecting it from direct internet exposure, allowing administrators to manage sync relationships and monitor transfer status through a properly secured web interface. This combination is perfect for small teams, home labs, and organizations that need reliable file synchronization without relying on third-party cloud providers, offering complete control over data location and access while maintaining the convenience of modern sync solutions.

## Features

- Peer-to-peer file synchronization without central servers or cloud dependency
- End-to-end AES encryption for all synchronized data with perfect forward secrecy
- Real-time conflict detection and resolution with versioning support
- Cross-platform device support including Windows, macOS, Linux, Android, and FreeBSD
- Selective folder synchronization with ignore patterns and partial sync capabilities
- NGINX reverse proxy with SSL termination and rate limiting for secure web interface access
- Block-level delta sync to minimize bandwidth usage on large files
- Web-based GUI for device management, folder configuration, and sync monitoring

## Use cases

- Home office setups synchronizing documents between desktop, laptop, and mobile devices
- Small development teams sharing code repositories and documentation without GitHub dependency
- Photography studios synchronizing RAW files and edited photos across workstations
- Family file sharing for photos, videos, and documents without cloud storage fees
- Remote workers maintaining synchronized project files across multiple locations
- Organizations with data sovereignty requirements keeping files on-premises
- Home lab enthusiasts creating personal cloud storage with multiple devices

## Prerequisites

- Minimum 256MB RAM available for Syncthing and 64MB for NGINX reverse proxy
- Open ports 8384 (web UI), 22000 (sync protocol), and 21027 (discovery) on firewall
- SSL certificates configured in NGINX for secure remote access to web interface
- Sufficient disk space on sync folders with at least 10% free space buffer
- Network connectivity between all devices that will participate in sync relationships
- Understanding of folder sharing permissions and device trust relationships

## docker-compose.yml

```yaml
services:
  syncthing:
    image: lscr.io/linuxserver/syncthing:latest
    environment:
      PUID: 1000
      PGID: 1000
      TZ: ${TZ}
    ports:
      - "8384:8384"
      - "22000:22000/tcp"
      - "22000:22000/udp"
      - "21027:21027/udp"
    volumes:
      - syncthing_config:/config
      - syncthing_data:/data
    networks:
      - syncthing-net
    restart: unless-stopped

  nginx:
    image: nginx:alpine
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - ./nginx.conf:/etc/nginx/nginx.conf:ro
    depends_on:
      - syncthing
    networks:
      - syncthing-net
    restart: unless-stopped

volumes:
  syncthing_config:
  syncthing_data:

networks:
  syncthing-net:
    driver: bridge
```

## .env

```bash
# Timezone
TZ=UTC

# User/Group IDs
PUID=1000
PGID=1000
```

## Usage notes

- Web UI at http://localhost:8384
- Add devices via device ID
- End-to-end encryption
- No central server required

## Troubleshooting

- Syncthing GUI shows 'Connection refused': Check that port 8384 is accessible and not blocked by firewall
- Devices not discovering each other: Verify port 21027/UDP is open for local discovery protocol
- Sync stuck at 0% with large files: Increase Syncthing's bandwidth limits in advanced settings
- NGINX 502 Bad Gateway errors: Ensure Syncthing container is running and accessible on port 8384
- Files not syncing despite connection: Check folder permissions and verify both devices have read/write access
- High CPU usage during sync: Enable Syncthing's built-in rate limiting to reduce resource consumption

