Sign inSign up

zweizs/anki-sync-server

By zweizs

Updated almost 2 years ago

Dockerized builtin Anki Sync Server (2.1.57+)

Image
Developer tools
Content management system
2

5.7K

zweizs/anki-sync-server repository overview

Anki Sync Server

Dockerized builtin Anki Sync Server (2.1.57+)

Tested

PlatformVersionRelease
Linux2.1.57-qt62.1.57
AnkiDroid2.15.62.1.57

Instructions

Reference the Anki manual on the builtin sync server for details on environment variables, adding multiple users, ect.

Security is your problem: this normally runs on an unencrypted port 8080. Setting up a reverse proxy with HTTPS is recommended. Sample configs below.

Set the Self-hosted sync server option under Preferences -> Syncing on Desktop. For AnkiDroid, use the same URL (with trailing slash) for the main sync URL and add /msync/ for the media URL (check the above documentation, this may change in the future). Make sure you set the protocol (http://) whenever you enter this address.

Note that 2.1.57 is not compatible with 2.1.57-1+ as the location of the virtual environment and data directory was separated (strongly recommend deleting the volume and re-syncing).

One-liner
docker run --name anki-sync-server -p 8080:8080 zweizs/anki-sync-server:latest
Volumes

/data in the container is used as a volume. If you change SYNC_BASE, you'll need to make sure to add a volume at the newly specified location.

Environment variables
VariableDefault Value
SYNC_USER1user:password
SYNC_BASE/data
SYNC_HOST0.0.0.0
SYNC_PORT8080
MAX_SYNC_UPLOAD_MEGS100
VENV_ROOT/venv
Sample configuration with Traefik
labels:
  traefik.http.services.anki.loadbalancer.server.port: "8080"

This would allow connecting to the Anki server through your main entrypoint (normally port 80/443).

Sample configuration with jwilder/nginx-proxy

This has not been tested

Set VIRTUAL_PORT environment variable to 8080.

If it doesn't work, it's possible it needs HTTP 1.0 support (as the older community Anki sync servers did) in which case try placing the following in /etc/nginx/proxy.conf:

# HTTP 1.0 support
proxy_http_version 1.0;
proxy_buffering off;
proxy_set_header Host $http_host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $proxy_connection;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $proxy_x_forwarded_proto;
proxy_set_header X-Forwarded-Ssl $proxy_x_forwarded_ssl;
proxy_set_header X-Forwarded-Port $proxy_x_forwarded_port;
proxy_set_header X-Forwarded-Path $request_uri;

# Mitigate httpoxy attack
proxy_set_header Proxy "";

Dev notes:

  • Github Action creates build with Docker tag based on tag format: anki-sync-server/v2.1.57
  • When no tag present, Action creates release with date

Available for Hire

I'm available for freelance, contracts, and consulting both remotely and in the Hudson Valley, NY (USA) area. Some more about me and what I can do for you.

Feel free to drop me a message at:

hi [a+] zweisolutions {●} com

License

Anki is licensed under GPLv3

This repo is MIT

Tag summary

Content type

Image

Digest

sha256:63f191db1

Size

82.4 MB

Last updated

almost 2 years ago

docker pull zweizs/anki-sync-server