Recently the amount of topics I want to study have grown substantially.  There's the new CCNA which is my primary focus, followed by learning a new language together with my wife.  Then there's a myriad of other tech topics that peak my interest like docker, pentesting, etc.  My company made the decision this week to have everyone work from home because of the Covid-19 virus.  This gives me at least 3 more hours to my day that would have been wasted in my commute.  

When it comes to studying my favorite flash card Software is Anki.  Anki is available on PC, Android and the Apple store.  They even have a free service to sync your flash cards across all of your devices.  For example you could be labbing and creating new flash cards on your PC, then walk to the bathroom to take a number two and study those exact same cards on your phone.  Anki is the best tool I've found to make flash cards but it's web syncing comes with a downside.  Because the service is free they have to clean out any unused decks to save on costs. If you end up not touching your account for 6 months you can kiss your flash cards good bye.  This is where self hosting your very own Anki web server comes in.  You'll use their great software, your data is on your own hardware, you'll never lose an inactive deck unless you decide to delete it, and it's fun!

So what did I use and how did I do it?

Quick side note, this method requires an older version of Anki that's still written in Python 2.0 .  Their current Anki software is written in Python 3.0 and doesn't support the modules used in these instructions.

Here's the container I used https://hub.docker.com/r/lertsenem/anki-server

I run UnRaid on my main home server and found a template for Anki that used the above container that I linked.  The template actually wasn't very good and didn't have the required fields but there isn't much the container needs anyways.  

The container only requires these fields:
Port: 27701:27701
File Path:  /localStorage/Anki:/anki

I like to keep all of my containers isolated on different bridges based on if it's internal facing or external facing; so this container was also set to my proxy network bridge with a static IP.  My NGINX container also sits on that same bridge and can redirect queries from the web to the IP address of the Anki-Server container itself instead of using the address of the physical computer.

After installing the server you need browse to the persistent storage for the Anki-Server container and modify the production.ini file.  You'll want to change the host IP.  In my picture below I changed the IP to match that of my Anki-Server container.

After saving the production.ini file go ahead and restart the Anki-Server container and when it comes back up login to the container via CLI.  We need to add users to the Anki-Server and we can do that with a script called ankiserverctl.py.  While in the CLI you can type ankiserverctl.py on it's own and you'll see a list of commands you can use with it (picture below).

To add a user you will need to call that python script followed by the adduser command and username to be added.  IE ankiserverctl.py adduser blog .  You'll then be asked for that users password.  Repeat this for all of the users you want to add.

Now go ahead and start your server by typing ankiserverctl.py start production.ini  .  You will only see a message if you did something incorrectly in the production.ini file.

This completes the Anki-Server portion.

Setting up your Anki program to sync to the server

You'll need to download an older version of Anki that's written in Python 2.0 .  After what felt like an eternity of troubleshooting I realized that the current version of Anki is written in Python 3.0 and so some of the commands in the module that we'll be importing have been deprecated.   Thankfully Anki hosts all versions of their computer program and anything version 2.0.x and below will work.  

Anki download archive
https://apps.ankiweb.net/downloads/archive/

After installing Anki go ahead and launch the software and go through the initial setup prompts.  When you're on the main screen go ahead and select the Tools dropdown followed by Add-ins then Open Add-ins folder.  This will open the Anki-Addon's directory for your PC.  

Create a file called mysyncserver.py in the add-ins directory and paste the below contents.  Make sure to change the IP address to that of your main server.

import anki.sync
anki.sync.SYNC_BASE = 'http://192.168.1.121:27701/'
anki.sync.SYNC_MEDIA_BASE = 'http://192.168.1.121:27701/msync/'

Save that file and re-launch Anki.  

When  Anki launches there is a circle icon in the top right of the window with a refresh icon.  Clicking that will prompt for your user credentials.  You can use the user account you created or the default account of username: anki password: anki

If you have any error messages about a Python issue on certain lines, you are running a newer version of Anki and need to download an older one still written in Python 2.0 (Anki version 2.0.x and below)

If you want to make your server internet facing

I setup a proxy_pass rule in my NGINX server to redirect any requests for a specific URL to the IP address of my Anki-Server container.

Maybe these instructions will help someone else out there.  Through a lot of my research I didn't find very many people who tried hosting their own Anki server and I found none who were trying to do it since Anki was re-written in Python 3.0.