Tutorial: Setup with k3d and nginx
This tutorial shows you how to set up Loculus on a plain Linux server that is reachable through a domain. For a local instance (i.e., an instance that is not publicly accessible), please check out this tutorial.
We will use k3d to run a Kubernetes cluster within Docker, nginx as a proxy server and Let’s Encrypt to obtain an SSL certificate. The tutorial was tested on an Ubuntu 24.04.
Prerequisites
- A Linux server (e.g. Ubuntu 24.04) with ideally at least 4 CPUs and 8 GB RAM
- A domain
- Install Docker: see this guide
- Install k3d: see this guide
- Install kubectl: see this guide
- Install Helm: see this guide
- Install nginx: see this guide
Step 1: Create a k3d cluster
We prepared a script that creates a k3d cluster, waits until the Traefik proxy in the cluster is ready and contains relevant port mappings. Create a file create-cluster.sh
with the following content, make it executable with chmod +x create-cluster.sh
and execute it with ./create-cluster.sh
.
Step 2: Install secret generator
The Loculus Helm chart uses the Mittwald secrets generator. You can install it with:
Step 3: Configure the instance
Create a file my-values.yaml
with the following configuration for the instance. Please enter your domain name (e.g., loculus.example.com
), define an initial admin password and give your instance a name. This instance uses a cluster-internal test database and a very simple organism. We will improve the configuration later.
Step 4: Install and deploy
Clone the Loculus repository. The Loculus Helm chart is located in kubernetes/loculus/
and you can install it with
Wait a few moments until everything gets started. You can see the status of the pods with:
Once the pods are running, the website is locally available (i.e., from within the sever) at port 9000 and you can download the HTML of the landing page with:
In the output, you should see somewhere:
Step 5: Configure DNS / domain
You have to add DNS entries of your domain to point to the server. Please add DNS entries for the following domains and sub-domains:
<your domain>
api.<your domain>
auth.<your domain>
Step 6: Set up nginx
Now, you can use nginx as a reverse proxy to make the instance publicly accessible through the domain.
First, delete the default nginx page with:
Next, create the config for Loculus at /etc/nginx/sites-enabled/loculus
with the following content and replace <your domain>
:
Reload nginx with
You should now be able to see the Loculus website at http://<your domain>
. Many links and features don’t work yet as they require SSL which we describe in the next step. For example, if you click on “Login”, you should see an error.
Step 7: Set up SSL certificates
You can use certbot to obtain SSL certificates from Let’s Encrypt. To install it, run:
Now, you can request the certificates with the following command:
You can now go back to your website at <your domain>
and should be able to create an account and use the instance!
Step 8: Use a dedicated database (important for production systems)
If you want to use the instance in production, it is important to use a database outside the Loculus Helm chart. The database that the Helm chart starts is purely for test purposes and might be reset during an update.
Loculus uses PostgreSQL as its database management system and requires two databases: one for the Loculus backend, and one for the Keycloak server. Please check out the official documentation for details on how to install PostgreSQL if you don’t have one already.
Then, adapt my-values.yaml
and add under the secrets
key:
To reinstall Loculus, execute:
Final words
Hopefully, you now have a working Loculus instance and can start adapting it to the organisms of your needs. Please check out the Helm chart config reference for information on the available configurations.