Configuration

Configuration

Environment Variables

The installer generates a .env file at /opt/ankibase/backend/.env. You can edit it manually if needed.

VariableDescriptionDefault
APP_SECRET_KEYSigns media links. Keep it secretAuto-generated
ANKIWEB_ENCRYPTION_KEYFernet key that encrypts stored API keysAuto-generated
APP_PORTBackend listen portFirst free port from 8000
CORS_ORIGINSOther origins allowed to call the API (only for a separately served frontend)http://localhost:<port>
UPDATE_CHANNELrelease (tagged releases) or main (every commit) for in-app updatesrelease
GEMINI_API_KEY, OPENAI_API_KEY, ANTHROPIC_API_KEYServer-wide AI keys for profiles without their own–

Without the two secrets in .env, AnkiBase generates them on first start into backend/data/.secrets (mode 0600). Per-profile data (stories, API keys) lives in backend/data/<profile>/.

After editing, restart the service:

systemctl restart ankibase

AI Providers

API keys are managed in the app under Settings → AI (or AI settings on the Story tab). Each provider has a default model, and you can switch models per story:

ProviderDefault modelAlso available
Anthropic (Claude)claude-opus-5-5claude-sonnet-5-5, claude-haiku-5-5
OpenAI (ChatGPT)gpt-4o-minigpt-4o, gpt-4-turbo, gpt-3.5-turbo
Google Geminigemini-2.0-flashgemini-2.0-flash-lite, gemini-1.5-flash-8b, gemini-1.5-pro

AI is optional. Studying, Quizlet, search and stats all work without a key.

Keys are saved per profile and encrypted at rest. Who may see or change them is a permission (see below).

Nginx

The installer can set up nginx automatically. If you need to configure it manually, here's the recommended config:

server {
    listen 80;
    server_name your-domain.com;
    return 301 https://$host$request_uri;
}
 
server {
    listen 443 ssl;
    server_name your-domain.com;
 
    ssl_certificate     /etc/letsencrypt/live/your-domain.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/your-domain.com/privkey.pem;
 
    client_max_body_size 500M;
 
    location / {
        proxy_pass         http://127.0.0.1:8000;
        proxy_set_header   Host $host;
        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 $scheme;
        proxy_read_timeout 300s;
    }
}

Users, profiles and permissions

A profile is an Anki collection: its own decks, media, review history, sync login, stories and Quizlet sets. A user is someone who logs in. Admins decide which profiles each user can use; switching profiles (the Profiles button) only affects that user's own login.

  • The first admin, created by the setup wizard, is the owner: only they can change their own account, and nobody can delete it. There's always at least one admin.
  • Admins can do everything. Members get permissions per user in Settings → Users: importing decks, using AI, managing AI keys, managing profiles, and changing the default theme.
  • Permission changes, removed profiles and deleted users take effect on the next request. Changing a password signs that user out everywhere else.

Profiles are cheap: they all share one Anki engine process, and a collection is only opened when it's used.

Sync

Each profile has its own sync login, set in Settings → Sync: AnkiWeb, or any self-hosted Anki sync server. Like Anki Desktop, only the sync key is kept (in /opt/ankibase/anki-data/anki-cli.json, readable by root only), never your password.

Your own sync server

Admins can run Anki's own sync server next to AnkiBase (Settings → Sync → Sync server on this AnkiBase): add an account and it starts, as the ankibase-sync service. AnkiBase serves it at https://<your AnkiBase>/syncserver/, so it uses your HTTPS setup and needs no extra port. Enter that address in Anki Desktop (Preferences → Syncing → self-hosted sync server), AnkiDroid (Settings → Advanced → custom sync server), AnkiMobile or the AnkiBase iPhone app. Collections are stored in /opt/ankibase/anki-data/.sync/data/<account>/.

Sync modes available:

  • Normal sync — incremental, merges changes
  • Full upload — overwrites the server's copy with this one
  • Full download — overwrites this copy with the server's

Updates

Update in the header (admins) installs the newest tagged release: AnkiBase downloads and builds it, checks that it starts, backs up your code and data to /opt/ankibase/backups/ (the last three are kept), installs it and restarts — and restores the backup if the new version doesn't come up. install.sh --update does the same from the command line.