Apache using Docker¶
This tutorial assumes that you have created a DNS A record for trilium.yourdomain.com
that you want to use for your Trilium server.
Docker setup¶
Download docker image and create container
docker pull triliumnext/trilium:[VERSION]
docker create --name trilium -t -p 127.0.0.1:8080:8080 -v ~/trilium-data:/home/node/trilium-data triliumnext/trilium:[VERSION]
Configuring the Apache proxy¶
-
Enable apache proxy modules
2. Create a new let's encrypt certificateChoose standalone (2) and note the location of the created certificates (typically /etc/letsencrypt/live/...) 3. Create a new virtual host file for apache (you may want to use
apachectl -S
to determine the server root location, mine is /etc/apache2)Paste (and customize) the following text into the configuration file
4. Enable the virtual host withServerName http://trilium.yourdomain.com RewriteEngine on RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,QSA,R=permanent] ServerName https://trilium.yourdomain.com RewriteEngine On RewriteCond %{HTTP:Connection} Upgrade [NC] RewriteCond %{HTTP:Upgrade} websocket [NC] RewriteRule /(.*) ws://localhost:8080/$1 [P,L] AllowEncodedSlashes NoDecode ProxyPass / http://localhost:8080/ nocanon ProxyPassReverse / http://localhost:8080/ SSLCertificateFile /etc/letsencrypt/live/trilium.yourdomain.com/fullchain.pem SSLCertificateKeyFile /etc/letsencrypt/live/trilium.yourdomain.com/privkey.pem Include /etc/letsencrypt/options-ssl-apache.conf
sudo a2ensite trilium.yourdomain.com.conf
5. Reload apache2 withsudo systemctl reload apache2
Configuring the trusted proxy¶
After setting up a reverse proxy, make sure to configure theĀ Trusted proxy.
Setup the systemd service to start up the server¶
Create and enable a systemd service to start the docker container on boot
-
Create a new empty file called
2. Install, enable and start service/lib/systemd/system/trilium.service
with the contents