Custom sync server - Anki does not initiate

There are various ways to achieve that, but I think one of the simplest methods is to configure a reverse proxy using Caddy. From this thread, it appears you’ve already experimented with Nginx, but if your goal is just to enable HTTPS, Caddy is much easier to configure. You can refer to the documentation here: Automatic HTTPS — Caddy Documentation.

Here’s an example configuration:

First, get your own domain name (if you don’t already have one).

Next, here is an example setup for an Anki custom sync server with Caddy:

.
├── CaddyFile 
├── Dockerfile
└── compose.yaml

CaddyFile

YOUR.DOMAIN.NAME {
    reverse_proxy anki-sync-server:8080
    log {
		output file /var/log/caddy/access.log
	}
}

Replace YOUR.DOMAIN.NAME with your own domain name.

Dockerfile

Use the Dockerfile provided by the Anki documentation.

compose.yaml

services:
  caddy-server:
    image: caddy:latest
    volumes:
      - ./Caddyfile:/etc/caddy/Caddyfile
      - ./caddy/config:/config
      - ./caddy/log:/var/log/caddy/
      # Location to store certificates and ACME information
      - ./caddy/data:/data
    ports:
      - "443:443"

  anki-sync-server:
    build:
      context: .
      args:
        ANKI_VERSION: 24.11
    tty: true
    environment:
      - SYNC_USER1=user:password
      - SYNC_BASE=/.syncserver
    volumes:
      - ./.syncserver:/.syncserver
    expose:
      - 8080

Finally, make sure to enter https://your.domain.name in the sync server field in the Anki client settings (for Desktop, AnkiDroid, or AnkiMobile). There’s no need to include a port number (it should work even if you explicitly specify port 443).

Screenshot

1 Like