Anki: Difference between revisions

Both unstable and stable host anki 25.09.2 and anki-bin 25.02.5 so anki is newer now
Added how to self host anki-sync-server, both behind a reverse proxy and plain, to the wiki. Feel free to make any critiques and edits necessary as this is my first time contributing to the wiki. The reason that the example client setup urls is like that is because in the clients it needs to be in that "http" or "https" setup.
 
Line 42: Line 42:


[[Category:Applications]]
[[Category:Applications]]
== Self Hosting ==
You can self host an instance of anki-sync-server via the NixOS module.
The default port for this service is 27701.
The most simplest setup for it you can have is like below:
;NixOS
services.anki-sync-server = {
  enable = true;
  address = "0.0.0.0";
  openFirewall = true;
  users = [
    {
      username = "bob";
      password = "password";
    }
  ];
};
You would then access the self hosted instance by changing it on the anki app you're using, but make sure to write as <code>http://ReplaceLocalIPHere:27701/</code> it is necessary to have the <code>/</code> at the end on the clients. After doing that, attempt to sync and when asked for log in details do, in this case <code>bob</code> as the email address and <code>password</code> as the password and it will work.
Note: This does let anyone on your local network access your anki-sync-server instance and it is exposed under http. It also exposes your password in plain text on the server. A better recommendation is to use the <code>passwordFile</code> option.
=== Reverse Proxy ===
You can reverse proxy anki-sync-server to make sure it's running under a https connection and in order to restrict it more to your vpn of choice.
A complete setup for that using caddy as the reverse proxy would be:
;NixOS
services.anki-sync-server = {
  enable = true;
  address = "127.0.0.1";
  users = [
    {
      username = "bob";
      password = "password";
    }
  ];
};
services.caddy.virtualHosts."anki.custom.domain".extraConfig = '''''''
  reverse_proxy ${config.services.anki-sync-server.address}:${builtins.toString config.services.anki-sync-server.port}
''''''';
Then to access that on your anki clients, you change the sync server to <code>https://anki.custom.domain/</code> that end <code>/</code> is important in order to get the clients working properly. Then you would log in with the "email address" as <code>bob</code> and the password as <code>password</code>
Note: It is still recommended to use the <code>passwordFile</code> option over the plain text <code>password</code> option as the latter option stores it in plain text in the nix store on the server.