Assumptions
- Memos is reached at
memos.xenonly.com.AandAAAArecords exist for this domain. - The Memos container uses port
127.0.0.1:8001. - Commands are run on the server with root rights (
sudo).
What It Is#
Memos is a light note app that you use in the browser and can host yourself.
Installation#
We’ll install it with Docker Compose.
sudo mkdir /opt/docker/memosLet’s create /opt/docker/memos/compose.yaml like this:
services:
memos:
image: neosmemo/memos:stable
container_name: memos
restart: unless-stopped
ports:
- "127.0.0.1:8001:5230"
volumes:
- ./data:/var/opt/memos
environment:
MEMOS_PORT: 5230
MEMOS_DRIVER: sqlite
MEMOS_INSTANCE_URL: "https://memos.xenonly.com"
MEMOS_TRUSTED_PROXIES: "172.20.0.0/16"Let’s start the container:
cd /opt/docker/memos
sudo docker compose up -dCertificate and NGINX Reverse Proxy#
Let’s get the certificate:
sudo certbot certonly --webroot -w /opt/www/well_known -d memos.xenonly.comLet’s create /etc/nginx/vhost.d/vhost_memos.xenonly.com.conf like this:
server {
listen 443 ssl;
listen [::]:443 ssl;
http2 on;
server_name memos.xenonly.com;
ssl_certificate /etc/letsencrypt/live/memos.xenonly.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/memos.xenonly.com/privkey.pem;
client_max_body_size 40m;
# Until the first account is created, remove afterwards
include /etc/nginx/templates/vpn-only.tmpl;
location / {
proxy_pass http://127.0.0.1:8001;
include /etc/nginx/templates/proxy.tmpl;
}
}client_max_body_size 40m: For files attached to notes. The 12m limit iRedMail sets is too small.
vpn-only.tmpl: In Memos, the first user who signs up becomes the admin. On a public address, if someone else creates the first account, they become the admin. So until the first account is created, Memos will be reachable only over the VPN.
Let’s test the NGINX configuration and reload it:
sudo nginx -t && sudo systemctl reload nginxFirst Account and Closing Sign-Ups#
- Let’s connect to the VPN with the full tunnel and create our own account at
https://memos.xenonly.com. - With the admin account, let’s close new user sign-ups by turning on Settings → System → Disallow user registration.
- Let’s delete the
include /etc/nginx/templates/vpn-only.tmpl;line in the virtual host and reload NGINX withsudo nginx -t && sudo systemctl reload nginx.
With a split tunnel, the domain resolves to the server’s public IP, so the request doesn’t go through the VPN and gets a 403 (see 7.3 Possible Problems).
Check#
curl -sI https://memos.xenonly.com | head -1 # HTTP/2 200Backup and Updates#
All of Memos’ data (the SQLite database and the uploaded files) is in the /opt/docker/memos/data directory; it is the only place that needs a backup.
To update:
cd /opt/docker/memos && sudo docker compose pull && sudo docker compose up -dcompose.yaml file, with their ports, volumes, networks and settings written down in one place. docker compose up -d applies the file.AllowedIPs = 0.0.0.0/0, ::/0), so the device goes out to the internet with the server’s IP address. See also split tunnel.10.8.0.0/24) goes through the tunnel; everything else uses the normal internet connection. See also full tunnel.server_name), so one server can host many domains.