Skip to content

Build your personal knowledge base with Trilium Notes

docs(auth): document the login rate limit and a safe trusted proxy setup

Elian Doran2fc535748f1d
diff --git a/apps/server/src/assets/config-sample.ini b/apps/server/src/assets/config-sample.ini
index 7fafd847e5..7bcdfbfb2e 100644
--- a/apps/server/src/assets/config-sample.ini
+++ b/apps/server/src/assets/config-sample.ini
@@ -18,11 +18,9 @@ https=false
# path to certificate (run "bash bin/generate-cert.sh" to generate self-signed certificate). Relevant only if https=true
certPath=
keyPath=
-# setting to give trust to reverse proxies, a comma-separated list of trusted rev. proxy IPs can be specified (CIDR notation is permitted),
-# alternatively 'true' will make use of the leftmost IP in X-Forwarded-For, ultimately an integer can be used to tell about the number of hops between
-# Trilium (which is hop 0) and the first trusted rev. proxy.
-# once set, expressjs will use the X-Forwarded-For header set by the rev. proxy to determinate the real IPs of clients.
+# comma-separated list of the IPs the reverse proxy connects from (CIDR notation is permitted), used to read the real IPs of clients from X-Forwarded-For.
# expressjs shortcuts are supported: loopback(127.0.0.1/8, ::1/128), linklocal(169.254.0.0/16, fe80::/10), uniquelocal(10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16, fc00::/7)
+# 'true' uses the leftmost IP in X-Forwarded-For, which clients can forge to get around the login rate limit unless the proxy overwrites the header.
trustedReverseProxy=false
# setting the CORS headers for cross-origin requests
diff --git a/apps/server/src/assets/help/help_content.json b/apps/server/src/assets/help/help_content.json
index d85d59bd2b..86bb14317c 100644
--- a/apps/server/src/assets/help/help_content.json
+++ b/apps/server/src/assets/help/help_content.json
@@ -18,12 +18,12 @@
"_help_vcjrb3VVYPZI": "<p>Trilium is typically exposed to the internet behind a <strong>reverse proxy</strong>, which handles TLS termination, presents a single public entry point, and (optionally) lets you host multiple instances under one domain. Trilium itself keeps running on plain HTTP on its local port; the proxy sits in front of it.</p><p>This section collects provider-specific guides and the configuration that applies regardless of which proxy you use.</p><h2>Provider guides</h2><ul><li><a class=\"reference-link\" href=\"#root/_help_ud6MShXL4WpO\">Nginx</a></li><li><a class=\"reference-link\" href=\"#root/_help_5ERVJb9s4FRD\">Traefik</a></li><li><a class=\"reference-link\" href=\"#root/_help_fDLvzOx29Pfg\">Apache using Docker</a></li></ul><h2>Applies to every proxy</h2><p>Regardless of the proxy you choose, make sure of the following:</p><ul><li><strong>Forward the WebSocket upgrade.</strong> Trilium uses a WebSocket for synchronization and live UI updates. Your proxy must pass the <code>Upgrade</code> and <code>Connection</code> headers through, otherwise the client will appear to load but never receive updates.</li><li><strong>Configure the trusted proxy.</strong> So that Trilium sees the real client IP (for rate limiting, logging, and secure cookies) rather than the proxy's address. See&nbsp;<a class=\"reference-link\" href=\"#root/_help_LLzSMXACKhUs\">Trusted proxy</a>.</li><li><strong>Terminate TLS at the proxy.</strong> See&nbsp;<a class=\"reference-link\" href=\"#root/_help_l2VkvOwUNfZj\">HTTPS (TLS)</a>.</li></ul><h2>Putting an authentication proxy in front of Trilium</h2><p>Some setups place a <strong>forward-auth / SSO layer</strong> (Authelia, Authentik, oauth2-proxy, or an OIDC plugin) at the proxy so that <em>every</em> request must pass an interactive login first.</p><p>This <strong>breaks synchronization and initial setup.</strong> Sync is a machine-to-machine process that runs unattended in the background — it has no browser and cannot complete an interactive login challenge. When the proxy intercepts a sync request, it returns its HTML login page instead of the expected JSON, and the client fails with an error such as:</p><pre><code class=\"language-text-x-trilium-auto\">Sync failed: Request to GET https://trilium.example.com/api/setup/status failed,\nerror: Unexpected token '&lt;', \"&lt;!doctype \"... is not valid JSON\n</code></pre><p>There are two ways to resolve this:</p><ul><li><strong>Preferred, use Trilium's built-in authentication.</strong> Don't gate Trilium at the proxy at all. Trilium can authenticate the web interface itself, including via <a href=\"#root/_help_x1lQNKQBqLcA\">OpenID Connect</a>. This leaves the sync endpoints free to authenticate the way they're designed to.</li><li><strong>Exempt the sync endpoints from the proxy's authentication.</strong> If you must keep auth at the proxy, exclude these paths from the forward-auth check:<ul><li><code>/api/setup/*</code></li><li><code>/api/login/sync</code></li><li><code>/api/sync/*</code></li></ul></li></ul><aside class=\"admonition note\"><p>This is safe: Trilium authenticates these endpoints itself. Sync uses a challenge-free HMAC handshake based on a shared secret, and the one-time setup seed request is password-protected — so exempting them at the proxy does not expose unauthenticated access to your data.</p></aside><p>An example for Nginx, where <code>/auth</code> is your forward-auth endpoint:</p><pre><code class=\"language-text-x-trilium-auto\">server {\n # ... TLS, server_name, etc. ...\n\n # Sync and setup endpoints authenticate themselves — skip forward-auth.\n location ~ ^/api/(sync|login/sync|setup) {\n auth_request off;\n proxy_set_header Host $host;\n proxy_set_header X-Real-IP $remote_addr;\n proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\n proxy_set_header X-Forwarded-Proto $scheme;\n proxy_set_header Upgrade $http_upgrade;\n proxy_set_header Connection \"upgrade\";\n proxy_pass http://trilium;\n }\n\n # Everything else goes through forward-auth.\n location / {\n auth_request /auth;\n proxy_set_header Host $host;\n proxy_set_header X-Real-IP $remote_addr;\n proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\n proxy_set_header X-Forwarded-Proto $scheme;\n proxy_set_header Upgrade $http_upgrade;\n proxy_set_header Connection \"upgrade\";\n proxy_pass http://trilium;\n }\n}</code></pre>",
"_help_ud6MShXL4WpO": "<p>Configure Nginx proxy and HTTPS. The operating system here is Ubuntu.</p><h2>Installing Nginx</h2><p>Download Nginx and remove Apache2</p><pre><code class=\"language-text-x-trilium-auto\">sudo apt-get install nginx\nsudo apt-get remove apache2</code></pre><h2>Build the configuration file</h2><ol><li><p>First, create the configuration file:</p><pre><code class=\"language-text-x-trilium-auto\">cd /etc/nginx/conf.d\nvim default.conf</code></pre></li><li><p>Fill the file with the context shown below, part of the setting show be changed. Then you can enjoy your web with HTTPS forced and proxy.</p><pre><code class=\"language-text-x-trilium-auto\"># This part configures, where your Trilium server is running\nupstream trilium {\n zone trilium 64k;\n server 127.0.0.1:8080; # change it to a different hostname and port if non-default is used\n keepalive 2;\n}\n\n# This part is for proxy and HTTPS configure\nserver {\n listen 443 ssl;\n server_name trilium.example.net; #change trilium.example.net to your domain without HTTPS or HTTP.\n ssl_certificate /etc/ssl/note/example.crt; #change /etc/ssl/note/example.crt to your path of crt file.\n ssl_certificate_key /etc/ssl/note/example.net.key; #change /etc/ssl/note/example.net.key to your path of key file.\n ssl_session_cache builtin:1000 shared:SSL:10m;\n ssl_protocols TLSv1 TLSv1.1 TLSv1.2;\n ssl_ciphers HIGH:!aNULL:!eNULL:!EXPORT:!CAMELLIA:!DES:!MD5:!PSK:!RC4;\n ssl_prefer_server_ciphers on;\n access_log /var/log/nginx/access.log; #check the path of access.log, if it doesn't fit your file, change it\n\n location / {\n proxy_set_header Host $host;\n proxy_set_header X-Real-IP $remote_addr;\n proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\n proxy_set_header X-Forwarded-Proto $scheme;\n proxy_set_header Upgrade $http_upgrade;\n proxy_set_header Connection \"upgrade\";\n proxy_pass http://trilium;\n proxy_read_timeout 90;\n }\n}\n\n# This part is for HTTPS forced\nserver {\n listen 80;\n server_name trilium.example.net; # change to your domain\n return 301 https://$server_name$request_uri;\n}</code></pre></li></ol><h2>Serving under a different path</h2><p>Alternatively if you want to serve the instance under a different path (useful e.g. if you want to serve multiple instances), update the location block like so:</p><ul><li>update the location with your desired path (make sure to not leave a trailing slash \"/\", if your <code>proxy_pass</code> does not end on a slash as well)</li><li>add the <code>proxy_cookie_path</code> directive with the same path: this allows you to stay logged in at multiple instances at the same time.</li></ul><pre><code class=\"language-text-x-trilium-auto\"> location /trilium/instance-one {\n rewrite /trilium/instance-one/(.*) /$1 break;\n proxy_set_header Host $host;\n proxy_set_header X-Real-IP $remote_addr;\n proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\n proxy_set_header X-Forwarded-Proto $scheme;\n proxy_set_header Upgrade $http_upgrade;\n proxy_set_header Connection \"upgrade\";\n proxy_pass http://trilium;\n proxy_cookie_path / /trilium/instance-one\n proxy_read_timeout 90;\n }</code></pre><h2>Configuring the trusted proxy</h2><p>After setting up a reverse proxy, make sure to configure the&nbsp;<a class=\"reference-link\" href=\"#root/_help_LLzSMXACKhUs\">Trusted proxy</a>.</p>",
"_help_fDLvzOx29Pfg": "<p>This tutorial assumes that you have created a DNS A record for <code>trilium.yourdomain.com</code> that you want to use for your Trilium server.</p><h2>Docker setup</h2><p>Download docker image and create container</p><pre><code class=\"language-text-x-trilium-auto\"> docker pull triliumnext/trilium:[VERSION]\n docker create --name trilium -t -p 127.0.0.1:8080:8080 -v ~/trilium-data:/home/node/trilium-data triliumnext/trilium:[VERSION]</code></pre><h2>Configuring the Apache proxy</h2><ol><li><p>Enable apache proxy modules</p><pre><code class=\"language-text-x-trilium-auto\"> a2enmod ssl\n a2enmod proxy\n a2enmod proxy_http\n a2enmod proxy_wstunnel</code></pre></li><li><p>Create a new let's encrypt certificate</p><pre><code class=\"language-text-x-trilium-auto\"> sudo certbot certonly -d trilium.mydomain.com</code></pre><p>Choose standalone (2) and note the location of the created certificates (typically /etc/letsencrypt/live/...)</p></li><li><p>Create a new virtual host file for apache (you may want to use <code>apachectl -S</code> to determine the server root location, mine is /etc/apache2)</p><pre><code class=\"language-text-x-trilium-auto\"> sudo nano /etc/apache2/sites-available/trilium.yourdomain.com.conf</code></pre><p>Paste (and customize) the following text into the configuration file</p><pre><code class=\"language-text-x-trilium-auto\"> \n ServerName http://trilium.yourdomain.com\n RewriteEngine on\n RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,QSA,R=permanent]\n \n \n ServerName https://trilium.yourdomain.com\n RewriteEngine On\n RewriteCond %{HTTP:Connection} Upgrade [NC]\n RewriteCond %{HTTP:Upgrade} websocket [NC]\n RewriteRule /(.*) ws://localhost:8080/$1 [P,L]\n AllowEncodedSlashes NoDecode\n ProxyPass / http://localhost:8080/ nocanon\n ProxyPassReverse / http://localhost:8080/\n SSLCertificateFile /etc/letsencrypt/live/trilium.yourdomain.com/fullchain.pem\n SSLCertificateKeyFile /etc/letsencrypt/live/trilium.yourdomain.com/privkey.pem\n Include /etc/letsencrypt/options-ssl-apache.conf\n </code></pre></li><li><p>Enable the virtual host with <code>sudo a2ensite trilium.yourdomain.com.conf</code></p></li><li><p>Reload apache2 with <code>sudo systemctl reload apache2</code></p></li></ol><h2>Configuring the trusted proxy</h2><p>After setting up a reverse proxy, make sure to configure the&nbsp;<a class=\"reference-link\" href=\"#root/_help_LLzSMXACKhUs\">Trusted proxy</a>.</p><h2>Setup the systemd service to start up the server</h2><p>Create and enable a systemd service to start the docker container on boot</p><ol><li><p>Create a new empty file called <code>/lib/systemd/system/trilium.service</code> with the contents</p><pre><code class=\"language-text-x-trilium-auto\"> [Unit]\n Description=Trilium Server\n Requires=docker.service\n After=docker.service\n\n [Service]\n Restart=always\n ExecStart=/usr/bin/docker start -a trilium\n ExecStop=/usr/bin/docker stop -t 2 trilium\n\n [Install]\n WantedBy=local.target</code></pre></li><li><p>Install, enable and start service</p><pre><code class=\"language-text-x-trilium-auto\"> sudo systemctl daemon-reload\n sudo systemctl enable trilium.service\n sudo systemctl start trilium.service</code></pre></li></ol>",
- "_help_LLzSMXACKhUs": "<p>If you are running the Trilium server under a <a href=\"#root/_help_vcjrb3VVYPZI\">reverse proxy</a>, it's important to configure it as a trusted proxy so that the application can correctly identify the real IP address of the clients (for authentication and rate limiting purposes).</p><p>To do so, simply modify&nbsp;<a class=\"reference-link\" href=\"#root/_help_Gzjqa934BdH4\">Configuration (config.ini or environment variables)</a>&nbsp;and set:</p><pre><code class=\"language-text-x-trilium-auto\">[Network]\ntrustedReverseProxy=true</code></pre><p>This will use the left-most IP in the <code>X-Forwarded-For</code> header. Alternatively, instead of <code>true</code> use the IP address of the reverse proxy or Express.js shortcuts such as:</p><pre><code class=\"language-text-x-trilium-auto\">loopback(127.0.0.1/8, ::1/128), linklocal(169.254.0.0/16, fe80::/10), uniquelocal(10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16, fc00::/7)</code></pre><p>For more information, consult <a href=\"https://expressjs.com/en/guide/behind-proxies.html\">Express behind proxies</a>.</p>",
+ "_help_LLzSMXACKhUs": "<p>If you are running the Trilium server under a <a href=\"#root/_help_vcjrb3VVYPZI\">reverse proxy</a>, it's important to configure it as a trusted proxy so that the application can correctly identify the real IP address of the clients. Trilium uses that address for <a href=\"#root/_help_0hzsNCP31IAB\">brute-force protection</a>, for the failed sign-in entries in its logs and to detect whether the connection was made over HTTPS.</p><p>Without this setting, every request appears to come from the reverse proxy, so all clients share a single limit of failed sign-in attempts.</p><h2>Configuring the trusted proxy</h2><p>To trust the reverse proxy, modify <a class=\"reference-link\" href=\"#root/_help_Gzjqa934BdH4\">Configuration (config.ini or environment variables)</a> and set <code>trustedReverseProxy</code> to the address the reverse proxy connects to Trilium from:</p><pre><code class=\"language-text-x-trilium-auto\">[Network]\ntrustedReverseProxy=loopback</code></pre><p>The value is a comma-separated list of IP addresses, subnets in CIDR notation or one of the following names:</p><figure class=\"table\"><table><thead><tr><th>Name</th><th>Addresses</th></tr></thead><tbody><tr><td><code>loopback</code></td><td><code>127.0.0.1/8</code>, <code>::1/128</code></td></tr><tr><td><code>linklocal</code></td><td><code>169.254.0.0/16</code>, <code>fe80::/10</code></td></tr><tr><td><code>uniquelocal</code></td><td><code>10.0.0.0/8</code>, <code>172.16.0.0/12</code>, <code>192.168.0.0/16</code>, <code>fc00::/7</code></td></tr></tbody></table></figure><p>Trilium then reads the client's address from the <code>X-Forwarded-For</code> header, taking the right-most entry that does not belong to a trusted address. Entries a client adds to the header are to the left of the ones the proxy appends, so they are ignored.</p><p>Common setups:</p><ul><li><strong>The reverse proxy runs on the same machine</strong>: use <code>loopback</code>.</li><li><strong>Trilium runs in Docker, with the reverse proxy on the host or in another container</strong>: use the subnet of the Docker network (for example <code>172.18.0.0/16</code>), or <code>uniquelocal</code> to cover every Docker network. With the environment variable: <code>TRILIUM_NETWORK_TRUSTEDREVERSEPROXY=172.18.0.0/16</code>.</li><li><strong>The reverse proxy runs on another machine</strong>: use its IP address.</li></ul><p>Only list addresses that the reverse proxy connects from. Any client connecting from a trusted address can claim to be another client through the <code>X-Forwarded-For</code> header. This matters for broad values such as <code>uniquelocal</code>: if devices on your local network can also reach Trilium directly, use the proxy's exact address instead.</p><aside class=\"admonition warning\"><p>Avoid setting <code>trustedReverseProxy=true</code>. It makes Trilium use the left-most entry of <code>X-Forwarded-For</code>, which is the value the client sent, unless the proxy discards the incoming header. Proxies usually append to it instead (such as Nginx's <code>$proxy_add_x_forwarded_for</code>), so a client can send a different address with every request and bypass the limit on failed sign-in attempts.</p></aside><p>For more information, consult <a href=\"https://expressjs.com/en/guide/behind-proxies.html\">Express behind proxies</a>.</p>",
"_help_5ERVJb9s4FRD": "<p>The goal of this article is to configure Traefik proxy and HTTPS. See <a href=\"https://github.com/TriliumNext/Trilium/issues/7768#issuecomment-3539165814\">#7768</a> for reference.</p><h2>Breaking change in Traefik 3.6.4</h2><p>Traefik 3.6.4 introduced a <a href=\"https://doc.traefik.io/traefik/migrate/v3/#encoded-characters-in-request-path\">breaking change</a> regarding how percent-encoded characters are handled in URLs. Trilium puts the title of an image or attachment in its URL path, so one whose title contains <code>#</code> or <code>/</code> is requested at a path such as <code>/api/images/…/diagram%231.png</code>. Traefik rejects these paths with HTTP 400, and the image does not load. Search is not affected, because it sends its text in a query parameter.</p><p>The easiest solution is to update to Traefik 3.6.7 or later which reverts this configuration change. Alternatively, the configuration can be changed according to the section below.</p><details class=\"trilium-collapsible\"><summary>Configuration change</summary><p>To solve this, the Traefik <a href=\"https://doc.traefik.io/traefik/getting-started/configuration-overview/#the-install-configuration\"><strong>static</strong> configuration</a> must be modified in order to allow those characters:</p><pre><code class=\"language-text-x-yaml\">entryPoints:\n web:\n http:\n encodedCharacters:\n allowEncodedSlash: true\n allowEncodedHash: true</code></pre><aside class=\"admonition tip\"><p>If images still fail to load, you might need to enable more encoded character groups. For more information, see <a href=\"https://github.com/TriliumNext/Trilium/issues/7968\">the relevant GitHub issue</a>; feel free to report your findings.</p></aside></details><h3>Build the docker-compose file</h3><p>Setting up Traefik as reverse proxy requires setting the following labels:</p><pre><code class=\"language-text-x-yaml\"> labels:\n - traefik.enable=true\n - traefik.http.routers.trilium.entrypoints=https\n - traefik.http.routers.trilium.rule=Host(`trilium.mydomain.tld`)\n - traefik.http.routers.trilium.tls=true\n - traefik.http.routers.trilium.service=trilium\n - traefik.http.services.trilium.loadbalancer.server.port=8080\n # scheme must be HTTP instead of the usual HTTPS because Trilium listens on HTTP internally\n - traefik.http.services.trilium.loadbalancer.server.scheme=http\n - traefik.docker.network=proxy\n # forward HTTP to HTTPS\n - traefik.http.routers.trilium.middlewares=trilium-headers@docker\n - traefik.http.middlewares.trilium-headers.headers.customrequestheaders.X-Forwarded-Proto=https</code></pre><h3>Setup needed environment variables</h3><p>After setting up a reverse proxy, make sure to configure the&nbsp;<a class=\"reference-link\" href=\"#root/_help_LLzSMXACKhUs\">Trusted proxy</a>.</p><h3>Example <code>docker-compose.yaml</code></h3><pre><code class=\"language-text-x-yaml\">services:\n trilium:\n image: triliumnext/trilium\n container_name: trilium\n networks:\n - traefik-proxy\n environment:\n - TRILIUM_NETWORK_TRUSTEDREVERSEPROXY=my-traefik-host-ip # e.g., 172.18.0.0/16\n volumes:\n - /path/to/data:/home/node/trilium-data\n - /etc/timezone:/etc/timezone:ro\n - /etc/localtime:/etc/localtime:ro\n labels:\n - traefik.enable=true\n - traefik.http.routers.trilium.entrypoints=https\n - traefik.http.routers.trilium.rule=Host(`trilium.mydomain.tld`)\n - traefik.http.routers.trilium.tls=true\n - traefik.http.routers.trilium.service=trilium\n - traefik.http.services.trilium.loadbalancer.server.port=8080\n # scheme must be HTTP instead of the usual HTTPS because of how trilium works\n - traefik.http.services.trilium.loadbalancer.server.scheme=http\n - traefik.docker.network=traefik-proxy\n # Tell Trilium the original request was HTTPS\n - traefik.http.routers.trilium.middlewares=trilium-headers@docker\n - traefik.http.middlewares.trilium-headers.headers.customrequestheaders.X-Forwarded-Proto=https\n\nnetworks:\n traefik-proxy:\n external: true</code></pre>",
"_help_l2VkvOwUNfZj": "<p>Configuring TLS is essential for <a href=\"#root/_help_WOcw2SLH6tbX\">server installation</a> in Trilium. This guide details the steps to set up TLS within Trilium itself.</p><aside class=\"admonition tip\"><p>While Trilium supports HTTPS on its own, it's generally a good idea to use a <a href=\"#root/_help_vcjrb3VVYPZI\">reverse proxy</a> instead with TLS termination. You can follow a <a href=\"https://www.digitalocean.com/community/tutorials/how-to-secure-nginx-with-let-s-encrypt-on-ubuntu-20-04\">guide like this</a> for such setups.</p></aside><h2>Obtaining a TLS Certificate</h2><p>You have two options for obtaining a TLS certificate:</p><ul><li><strong>Recommended</strong>: Obtain a TLS certificate signed by a root certificate authority. For personal use, <a href=\"https://letsencrypt.org\">Let's Encrypt</a> is an excellent choice. It is free, automated, and straightforward. Certbot can facilitate automatic TLS setup.</li><li>Generate a self-signed certificate. This option is not recommended due to the additional complexity of importing the certificate into all machines connecting to the server.</li></ul><h2>Modifying <code>config.ini</code></h2><p>Once you have your certificate, modify the <code>config.ini</code> file in the <a href=\"#root/_help_tAassRL4RSQL\">data directory</a> to configure Trilium to use it:</p><pre><code class=\"language-text-x-trilium-auto\">[Network]\nport=8080\n# Set to true for TLS/SSL/HTTPS (secure), false for HTTP (insecure).\nhttps=true\n# Path to the certificate (run \"bash bin/generate-cert.sh\" to generate a self-signed certificate).\n# Relevant only if https=true\ncertPath=/[username]/.acme.sh/[hostname]/fullchain.cer\nkeyPath=/[username]/.acme.sh/[hostname]/example.com.key</code></pre><p>You can also review the <a href=\"#root/_help_Gzjqa934BdH4\">configuration</a> file to provide all <code>config.ini</code> values as environment variables instead. For example, you can configure TLS using environment variables:</p><pre><code class=\"language-text-x-trilium-auto\">export TRILIUM_NETWORK_HTTPS=true\nexport TRILIUM_NETWORK_CERTPATH=/path/to/cert.pem\nexport TRILIUM_NETWORK_KEYPATH=/path/to/key.pem</code></pre><p>The above example shows how this is set up in an environment where the certificate was generated using Let's Encrypt's ACME utility. Your paths may differ. For Docker installations, ensure these paths are within a volume or another directory accessible by the Docker container, such as <code>/home/node/trilium-data/[DIR IN DATA DIRECTORY]</code>.</p><p>After configuring <code>config.ini</code>, restart Trilium and access the hostname using \"https\".</p><h2>Self-Signed Certificate</h2><p>If you opt to use a self-signed certificate for your server instance, note that the desktop instance will not trust it by default.</p><p>To bypass this, disable certificate validation by setting the following environment variable (for Linux):</p><pre><code class=\"language-text-x-trilium-auto\">export NODE_TLS_REJECT_UNAUTHORIZED=0\ntrilium</code></pre><p>Trilium provides scripts to start in this mode, such as <code>trilium-no-cert-check.bat</code> for Windows.</p><p><strong>Warning</strong>: Disabling TLS certificate validation is insecure. Proceed only if you fully understand the implications.</p>",
- "_help_0hzsNCP31IAB": "<h2>Disabling authentication</h2><p>If you are running Trilium on <code>localhost</code> only or if authentication is handled by another component, you can disable Trilium’s authentication by adding the following to <code>config.ini</code>:</p><pre><code class=\"language-text-x-trilium-auto\">[General]\nnoAuthentication=true</code></pre><p>Disabling authentication will bypass even the&nbsp;<a class=\"reference-link\" href=\"#root/_help_7DAiwaf8Z7Rz\">Multi-Factor Authentication</a>&nbsp;since v0.94.1.</p><h2>Understanding how the session works</h2><p>Once logged into Trilium, the application will store this information about the login into a cookie on the browser, but also as a session on the server.</p><p>If “Remember me” is checked, then the login will expire in 21 days. This period can be adjusted by modifying the <code>Session.cookieMaxAge</code> value in <code>config.ini</code>. For example, to have the session expire in one day:</p><pre><code class=\"language-text-x-trilium-auto\">[Session]\ncookieMaxAge=86400</code></pre><p>When “Remember me” is unchecked, the behavior is different. At client/browser level the authentication does not have any expiration date, but it will be automatically cleared as soon as the user closes the browser. Nevertheless, the server will also dismiss this authentication in around 24 hours from the <em>last interaction with the application</em>.</p><h2>Viewing active sessions</h2><p>The login sessions are now stored in the same&nbsp;<a class=\"reference-link\" href=\"#root/_help_wX4HbRucYSDD\">Database</a>&nbsp;as the user data. In order to view which sessions are active, open the&nbsp;<a class=\"reference-link\" href=\"#root/_help_YKWqdJhzi2VY\">SQL Console</a>&nbsp;and run the following query:</p><pre><code class=\"language-text-x-trilium-auto\">SELECT * FROM sessions</code></pre><p>Expired sessions are periodically cleaned by the server, generally an hourly interval.</p><h2>See also</h2><ul><li><a class=\"reference-link\" href=\"#root/_help_7DAiwaf8Z7Rz\">Multi-Factor Authentication</a></li></ul>",
+ "_help_0hzsNCP31IAB": "<h2>Disabling authentication</h2><p>If you are running Trilium on <code>localhost</code> only or if authentication is handled by another component, you can disable Trilium’s authentication by adding the following to <code>config.ini</code>:</p><pre><code class=\"language-text-x-trilium-auto\">[General]\nnoAuthentication=true</code></pre><p>Disabling authentication will bypass even the&nbsp;<a class=\"reference-link\" href=\"#root/_help_7DAiwaf8Z7Rz\">Multi-Factor Authentication</a>&nbsp;since v0.94.1.</p><h2>Brute-force protection</h2><p>Trilium limits each IP address to 10 failed sign-in attempts in 15 minutes. Once an address reaches the limit, Trilium rejects every further attempt from it, including correct ones, until the 15 minutes have passed. The sign-in page then shows <em>Too many login attempts</em>; other clients receive HTTP status 429.</p><p>The limit applies to every way of signing in with the password:</p><ul><li>The sign-in page.</li><li>Setting up&nbsp;<a class=\"reference-link\" href=\"#root/_help_cbkrhQjrkKrh\">Synchronization</a> from a desktop or mobile app.</li><li>Connecting the&nbsp;<a class=\"reference-link\" href=\"#root/_help_MtPxeAWVAzMg\">Web Clipper</a> or the Android sender app.</li><li>Requesting a token through&nbsp;<a class=\"reference-link\" href=\"#root/_help_pgxEVkzLl1OP\">ETAPI (REST API)</a>.</li></ul><p>All of these count toward the same limit, and a wrong password, a wrong one-time password and a wrong recovery code each count as one failed attempt. Successful sign-ins are not counted.</p><p>The limit is per IP address, not per account, so an attacker cannot lock you out by failing to sign in from their own address. The count is kept in memory: restarting the server clears it.</p><aside class=\"admonition important\"><p>Behind a reverse proxy, Trilium sees every request as coming from the proxy unless it is configured as a&nbsp;<a class=\"reference-link\" href=\"#root/_help_LLzSMXACKhUs\">Trusted proxy</a>. All clients then share a single limit, so a few wrong attempts from anyone block everyone.</p></aside><h3>Blocking repeated failures with fail2ban</h3><p>A failed attempt on the sign-in page is answered with HTTP status 401 and recorded in the&nbsp;<a class=\"reference-link\" href=\"#root/_help_bnyigUA2UK7s\">Backend (server) logs</a> as:</p><pre><code class=\"language-text-x-trilium-auto\">WARNING: Wrong password from 203.0.113.7, rejecting.</code></pre><p>When&nbsp;<a class=\"reference-link\" href=\"#root/_help_7DAiwaf8Z7Rz\">Multi-Factor Authentication</a> is enabled, a wrong one-time password or recovery code is logged as <code>Wrong totp</code> instead. Tools such as fail2ban can match either the log line or the 401 responses to <code>POST /login</code> in the reverse proxy's access log to block an address for longer than 15 minutes.</p><h2>Understanding how the session works</h2><p>Once logged into Trilium, the application will store this information about the login into a cookie on the browser, but also as a session on the server.</p><p>If “Remember me” is checked, then the login will expire in 21 days. This period can be adjusted by modifying the <code>Session.cookieMaxAge</code> value in <code>config.ini</code>. For example, to have the session expire in one day:</p><pre><code class=\"language-text-x-trilium-auto\">[Session]\ncookieMaxAge=86400</code></pre><p>When “Remember me” is unchecked, the behavior is different. At client/browser level the authentication does not have any expiration date, but it will be automatically cleared as soon as the user closes the browser. Nevertheless, the server will also dismiss this authentication in around 24 hours from the <em>last interaction with the application</em>.</p><h2>Viewing active sessions</h2><p>The login sessions are now stored in the same&nbsp;<a class=\"reference-link\" href=\"#root/_help_wX4HbRucYSDD\">Database</a>&nbsp;as the user data. In order to view which sessions are active, open the&nbsp;<a class=\"reference-link\" href=\"#root/_help_YKWqdJhzi2VY\">SQL Console</a>&nbsp;and run the following query:</p><pre><code class=\"language-text-x-trilium-auto\">SELECT * FROM sessions</code></pre><p>Expired sessions are periodically cleaned by the server, generally an hourly interval.</p><h2>See also</h2><ul><li><a class=\"reference-link\" href=\"#root/_help_7DAiwaf8Z7Rz\">Multi-Factor Authentication</a></li><li><a class=\"reference-link\" href=\"#root/_help_LLzSMXACKhUs\">Trusted proxy</a></li></ul>",
"_help_lwAX5SvbrK2g": "<aside class=\"admonition important\"><p>If you forget your password:</p><ul><li>Protected notes are irretrievable without the password.</li><li>Unprotected notes can be recovered.</li></ul></aside><p>There are two options, both involving access to the device that is running your server.</p><h3>By disabling authentication</h3><ol><li>See&nbsp;<a class=\"reference-link\" href=\"#root/_help_0hzsNCP31IAB\">Authentication</a>&nbsp;on how to disable the authentication.</li><li>Restart the server.</li><li>Go to&nbsp;<a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a>&nbsp;→ Password → Reset password.</li><li>Re-enable authentication by following step (1) in reverse.</li><li>Restart the server.</li><li>Log in with the new password.</li></ol><h3>By altering the database</h3><ol><li><p>Access the <a href=\"#root/_help_wX4HbRucYSDD\">database</a> file in the <a href=\"#root/_help_tAassRL4RSQL\">data directory</a>. Open the <code>document.db</code> file with an SQLite client (e.g., <a href=\"https://sqlitebrowser.org/\">DB Browser</a>).</p></li><li><p>Execute the following queries:</p><pre><code class=\"language-text-x-trilium-auto\">UPDATE options SET value = '77/twC5O00cuQgNC63VK32qOKKYwj21ev3jZDXoytVU=' WHERE name = 'passwordVerificationSalt';\nUPDATE options SET value = '710BMasZCAgibzIc07X4P9Q4TeBd4ONnqJOho+pWcBM=' WHERE name = 'passwordDerivedKeySalt';\nUPDATE options SET value = 'Eb8af1/T57b89lCRuS97tPEl4CwxsAWAU7YNJ77oY+s=' WHERE name = 'passwordVerificationHash';\nUPDATE options SET value = 'QpC8XoiYYeqHPtHKRtbNxfTHsk+pEBqVBODYp0FkPBa22tlBBKBMigdLu5GNX8Uu' WHERE name = 'encryptedDataKey';</code></pre></li><li><p>After executing the changes, commit/write the changes. <strong>This sets the password to</strong> <code>**password**</code><strong>, allowing you to log in again.</strong></p></li><li><p>Go to&nbsp;<a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a>&nbsp;→ <em>Password</em> → <em>Change password</em> and replace the unsafe password.</p></li></ol><h2>Handling protected notes</h2><p>When the password is reset, the protected notes are permanently lost due to the fact that they are encrypted with your password so there is no way for Trilium to recover them.</p><p>For pre-existing protected notes (now unrecoverable), consider deleting them or exporting the unprotected notes. Then, delete <code>document.db</code> and start fresh.</p>",
- "_help_7DAiwaf8Z7Rz": "<p>Multi-factor authentication (MFA) is a security process that requires users to provide two or more verification factors to gain access to a system, application, or account. This adds an extra layer of protection beyond just using a password.</p><p>By requiring more than one verification method, MFA helps reduce the risk of unauthorized access, even if someone has obtained your password. It’s highly recommended for securing sensitive information stored in your notes.</p><h2>Relationship to OpenID Connect (OIDC)</h2><p>Multi-factor authentication makes your Trilium login safer by requiring an additional proof of identity apart from your password.&nbsp;<a class=\"reference-link\" href=\"#root/_help_x1lQNKQBqLcA\">Signing in with OpenID Connect</a>&nbsp;is a different concept which delegates your authentication to an external provider (e.g. your Google provider, or a self-hosted one such as Authelia). These authentication providers might provide their own security features such as TOTP or passkeys.</p><h2>Time-based one-time password (TOTP)</h2><p>TOTP (Time-Based One-Time Password) is a security feature that generates a unique, temporary code on your device, like a smartphone, which changes every 30 seconds. You use this code, along with your password, to log into your account, making it much harder for anyone else to access them.</p><ol><li>Go to&nbsp;<a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a>&nbsp;→ <em>Password &amp; Auth.</em></li><li>Make sure <em>Sign-in with</em> has <em>Local password</em> selected.</li><li>In the <em>Two-factor authentication</em> section, press <em>Set up.</em></li><li>Scan the QR code or manually enter the code in your authenticator app.</li><li>Enter the verification code from your authenticator app to confirm that the setup was successful and press <em>Verify &amp; continue</em>.</li><li>Save the recovery codes, then tick the confirmation and press <em>Finish setup</em>.</li><li>Re-login will be required after TOTP setup is finished (After you refreshing the page).</li></ol><h2>Connecting a device to the server</h2><p>Once TOTP is enabled, connecting a new desktop or mobile app to the server through <a class=\"reference-link\" href=\"#root/_help_cbkrhQjrkKrh\">Synchronization</a> also asks for the second factor. On the <em>Connect to an existing server</em> screen, enter a one-time password or a recovery code in <em>One-time password or recovery code</em>, below the server's password. Without it, the server refuses to set up the sync.</p><p>The second factor is only asked for when a device is first connected. A device that is already set up keeps syncing without it.</p><aside class=\"admonition note\"><p>Versions prior to v0.107.0 do not ask for the second factor when setting up the sync. Update the desktop and mobile apps along with the server, since older apps have no field to send it.</p></aside><h2>Recovery codes</h2><p>Recovery codes can be used in place of the TOTP if you lose access to your authenticator. Trilium provides 8 different recovery codes, each recovery code can be used once.</p><p>To use a recovery code, simply login with your password and use the recovery code as the security token.</p><p>The initial set of recovery codes is generated when setting up your TOTP for the first time. They can be regenerated at any time by going to &nbsp;<a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a>&nbsp;→ <em>Password &amp; Auth</em> and pressing the <em>Regenerate recovery codes</em> button. This will generate a new set of recovery codes while at the same time disabling the previous ones.</p>",
+ "_help_7DAiwaf8Z7Rz": "<p>Multi-factor authentication (MFA) is a security process that requires users to provide two or more verification factors to gain access to a system, application, or account. This adds an extra layer of protection beyond just using a password.</p><p>By requiring more than one verification method, MFA helps reduce the risk of unauthorized access, even if someone has obtained your password. It’s highly recommended for securing sensitive information stored in your notes.</p><h2>Relationship to OpenID Connect (OIDC)</h2><p>Multi-factor authentication makes your Trilium login safer by requiring an additional proof of identity apart from your password.&nbsp;<a class=\"reference-link\" href=\"#root/_help_x1lQNKQBqLcA\">Signing in with OpenID Connect</a>&nbsp;is a different concept which delegates your authentication to an external provider (e.g. your Google provider, or a self-hosted one such as Authelia). These authentication providers might provide their own security features such as TOTP or passkeys.</p><h2>Time-based one-time password (TOTP)</h2><p>TOTP (Time-Based One-Time Password) is a security feature that generates a unique, temporary code on your device, like a smartphone, which changes every 30 seconds. You use this code, along with your password, to log into your account, making it much harder for anyone else to access them.</p><ol><li>Go to&nbsp;<a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a>&nbsp;→ <em>Password &amp; Auth.</em></li><li>Make sure <em>Sign-in with</em> has <em>Local password</em> selected.</li><li>In the <em>Two-factor authentication</em> section, press <em>Set up.</em></li><li>Scan the QR code or manually enter the code in your authenticator app.</li><li>Enter the verification code from your authenticator app to confirm that the setup was successful and press <em>Verify &amp; continue</em>.</li><li>Save the recovery codes, then tick the confirmation and press <em>Finish setup</em>.</li><li>Re-login will be required after TOTP setup is finished (after refreshing the page).</li></ol><h2>Signing in</h2><p>Once TOTP is enabled, the sign-in page asks for the code from your authenticator app in <em>One-time password or recovery code</em>, below the password.</p><p>Trilium accepts the code for the current 30-second period as well as the periods just before and after it, so a clock that is slightly off on either side still works. Since v0.106.0, each code is accepted only once: after a successful sign-in, that code and any older one are rejected, even while they are still valid.</p><p>A wrong one-time password counts toward the same limit of failed attempts as a wrong password. See <em>Brute-force protection</em> in&nbsp;<a class=\"reference-link\" href=\"#root/_help_0hzsNCP31IAB\">Authentication</a>.</p><h2>Connecting a device to the server</h2><p>Once TOTP is enabled, connecting a new desktop or mobile app to the server through <a class=\"reference-link\" href=\"#root/_help_cbkrhQjrkKrh\">Synchronization</a> also asks for the second factor. On the <em>Connect to an existing server</em> screen, enter a one-time password or a recovery code in <em>One-time password or recovery code</em>, below the server's password. Without it, the server refuses to set up the sync.</p><p>The second factor is only asked for when a device is first connected. A device that is already set up keeps syncing without it.</p><aside class=\"admonition note\"><p>Versions prior to v0.107.0 do not ask for the second factor when setting up the sync. Update the desktop and mobile apps along with the server, since older apps have no field to send it.</p></aside><h2>Recovery codes</h2><p>Recovery codes can be used in place of the TOTP if you lose access to your authenticator. Trilium provides 8 different recovery codes, each recovery code can be used once.</p><p>To use a recovery code, simply login with your password and use the recovery code as the security token.</p><p>The initial set of recovery codes is generated when setting up your TOTP for the first time. They can be regenerated at any time by going to &nbsp;<a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a>&nbsp;→ <em>Password &amp; Auth</em> and pressing the <em>Regenerate recovery codes</em> button. This will generate a new set of recovery codes while at the same time disabling the previous ones.</p>",
"_help_x1lQNKQBqLcA": "<p>OpenID is a standardized way to let you log into websites using an account from another service, like Google or Authelia, to verify your identity.</p><p>When OpenID is activated, the password-based authentication in Trilium is replaced with a button that connects using your provider. This means that the configuration of&nbsp;<a class=\"reference-link\" href=\"#root/_help_7DAiwaf8Z7Rz\">Multi-factor authentication with TOTP</a>&nbsp;no longer takes effect, since your provider has to handle any multi-factor authentication.</p><h2>Setup</h2><p>Setting up authentication with OpenID connect is a two-step process:</p><ol><li>First the Trilium server must be configured with information about your authentication provider such as the URL, client ID and secret.</li><li>Second, the user must connect from options to create a link between the account on the provider and the one Trilium has.</li></ol><h3>Configuring the authentication provider</h3><ol><li><p>First, make sure the authentication provider (e.g. Google, Authelia) is configured properly. See&nbsp;<a class=\"reference-link\" href=\"#root/_help_IgkTHSaFfq6A\">Setting up with various providers</a>&nbsp;for concrete examples.</p><ol><li>The redirect URL of Trilium is <code>https://&lt;your-trilium-domain&gt;/callback</code>.</li><li>You should obtain the base URL, client ID and client secret.</li></ol></li><li><p>Set the following information using&nbsp;<a class=\"reference-link\" href=\"#root/_help_Gzjqa934BdH4\">Configuration (config.ini or environment variables)</a>:</p><figure class=\"table\"><table><thead><tr><th>Configuration</th><th><code>config.ini</code> in <code>[MultiFactorAuthentication]</code> section</th><th>Environment variable</th><th>Description</th></tr></thead><tbody><tr><td>Base URL*</td><td><code>oauthBaseUrl</code></td><td><code>TRILIUM_MULTIFACTORAUTHENTICATION_OAUTHBASEURL</code></td><td>The URL of your Trilium instance (e.g. <code>https://example.com</code>).</td></tr><tr><td>Client ID*</td><td><code>oauthClientId</code></td><td><code>TRILIUM_MULTIFACTORAUTHENTICATION_OAUTHCLIENTID</code></td><td>The client ID from your provider configuration.</td></tr><tr><td>Client Secret*</td><td><code>oauthClientSecret</code></td><td><code>TRILIUM_MULTIFACTORAUTHENTICATION_OAUTHCLIENTSECRET</code></td><td>The client secret from your provider configuration.</td></tr><tr><td>Client auth method</td><td><code>oauthClientAuthMethod</code></td><td><code>TRILIUM_MULTIFACTORAUTHENTICATION_OAUTHCLIENTAUTHMETHOD</code></td><td>Token-endpoint auth method: <code>client_secret_basic</code> or <code>client_secret_post</code>. Empty auto-detects. &nbsp;Only needed if sign-in fails with a <code>WWW-Authenticate</code> or <code>invalid_client</code> error.</td></tr><tr><td>ID token algorithm</td><td><code>oauthIdTokenSigningAlg</code></td><td><code>TRILIUM_MULTIFACTORAUTHENTICATION_OAUTHIDTOKENSIGNINGALG</code></td><td><span style=\"color:rgb(32,32,32);\">The algorithm your provider signs ID tokens with, e.g.</span> <code>RS256</code><span style=\"color:rgb(32,32,32);\">,</span> <code>EdDSA</code><span style=\"color:rgb(32,32,32);\">,</span> <code>ES256</code><span style=\"color:rgb(32,32,32);\">. Empty auto-detects from the provider. Only needed if sign-in fails with an</span> <code>unexpected JWT alg</code> <span style=\"color:rgb(32,32,32);\">error.</span></td></tr></tbody></table></figure><p>Asterisk (*) marks a required field</p></li><li><p>The default OAuth issuer is Google. To use other services such as Authentik or Auth0, you can configure the settings via <code>oauthIssuerBaseUrl</code>, <code>oauthIssuerName</code>, and <code>oauthIssuerIcon</code> in the <code>config.ini</code> file. Alternatively, these values can be set using environment variables:</p><figure class=\"table\"><table><thead><tr><th>Configuration</th><th><code>config.ini</code> in <code>[MultiFactorAuthentication]</code> section</th><th>Environment variable</th><th>Description</th></tr></thead><tbody><tr><td>Issuer base URL</td><td><code>oauthIssuerBaseUrl</code></td><td><code>TRILIUM_MULTIFACTORAUTHENTICATION_OAUTHISSUERBASEURL</code></td><td>Either the issuer itself (<code>https://auth.example.com</code>) or a full discovery URL (<code>https://auth.example.com/.well-known/openid-configuration</code>). <br> <br>A URL containing <code>/.well-known/</code> is used as-is<span style=\"color:rgb(32,32,32);\">, which is convenient when your provider hands you a discovery URL to copy. A trailing slash may be included or omitted; Trilium matches whichever spelling the provider advertises.</span> <br> <br>Use the full form when your provider advertises an issuer that differs from the path serving its discovery document, such as Authentik in \"global\" issuer mode.</td></tr><tr><td>Issuer name</td><td><code>oauthIssuerName</code></td><td><code>TRILIUM_MULTIFACTORAUTHENTICATION_OAUTHISSUERNAME</code></td><td>The name of your authentication provider, used for reference on the login screen and in settings. Default is “Google”.</td></tr><tr><td>Issuer icon</td><td><code>oauthIssuerIcon</code></td><td><code>TRILIUM_MULTIFACTORAUTHENTICATION_OAUTHISSUERICON</code></td><td>Optionally, the URL to a logo of the provider. By default it will try to obtain the favicon from the website, so it's optional.</td></tr></tbody></table></figure><p>All the fields here are optional, since the default OAuth issuer is Google.</p></li><li><p>Optionally, tune the following advanced settings. All are optional and have sensible defaults:</p><figure class=\"table\"><table><thead><tr><th>Configuration</th><th><code>config.ini</code> in <code>[MultiFactorAuthentication]</code> section</th><th>Environment variable</th><th>Description</th></tr></thead><tbody><tr><td>HTTP timeout</td><td><code>oauthHttpTimeout</code></td><td><code>TRILIUM_MULTIFACTORAUTHENTICATION_OAUTHHTTPTIMEOUT</code></td><td>Timeout in milliseconds for the provider HTTP requests (discovery, token exchange, userinfo). Defaults to <code>30000</code> (30s). Raise this if your provider cold-starts slowly and you are occasionally asked to sign in twice. Minimum accepted value is <code>500</code>.</td></tr><tr><td>Scopes</td><td><code>oauthScope</code></td><td><code>TRILIUM_MULTIFACTORAUTHENTICATION_OAUTHSCOPE</code></td><td>Space-separated list of OIDC scopes requested at login. Defaults to <code>openid profile email</code>. <code>openid</code> is required and is prepended automatically if you omit it.</td></tr></tbody></table></figure><p>The OIDC session lifetime is automatically bound to Trilium's own session cookie lifetime (the <code>cookieMaxAge</code> setting in the <code>[Session]</code> section, 21 days by default), so a single sign-in stays valid for as long as your Trilium session does rather than expiring early on the OIDC library's shorter internal defaults.</p></li><li><p>Restart the server so that the changes are applied.</p></li></ol><aside class=\"admonition note\"><p>Legacy environment variables are also supported: <code>TRILIUM_OAUTH_BASE_URL</code>, <code>TRILIUM_OAUTH_CLIENT_ID</code>, <code>TRILIUM_OAUTH_CLIENT_SECRET</code>, and for customizing the provider: <code>TRILIUM_OAUTH_ISSUER_BASE_URL</code>, <code>TRILIUM_OAUTH_ISSUER_NAME</code>, <code>TRILIUM_OAUTH_ISSUER_ICON</code>, <code>TRILIUM_OAUTH_HTTP_TIMEOUT</code>, <code>TRILIUM_OAUTH_SCOPE</code>, <code>TRILIUM_OAUTH_CLIENT_AUTH_METHOD</code>, <code>TRILIUM_OAUTH_ID_TOKEN_SIGNING_ALG</code>.</p></aside><h2>Connecting to the authentication provider</h2><p>Once the server has been configured at the previous step, the next step is to create a link between your account on the authentication provider and the Trilium instance. This makes sure that only you can access the Trilium instance, and not just any other valid account.</p><p>To do so:</p><ol><li>Go to&nbsp;<a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a>&nbsp;→ <em>Password &amp; Auth.</em></li><li>In the <em>Sign-in with</em> field, choose <em>OpenID Connect provider.</em></li><li>In the <em>OpenID Connect</em> section, look for the <em>Connect account</em> (<span class=\"tn-icon bx bx-log-in\"></span>) button.</li><li>This will redirect you to your authentication provider, where you can sign in or confirm the action if needed.</li><li>Once you are authenticated you will be redirected back to the Trilium application.</li></ol><h2>Logging out</h2><p>When logging out of Trilium, a request is made to the authentication provider to log out from there as well. This feature depends on the authentication provider, so it may not be honored (Google and Authelia are known cases in which they don't respect the logout feature).</p><h2>Switching providers</h2><p>When switching providers (e.g. going from Google to Authelia), it's important to take the following steps:</p><ol><li>Go to&nbsp;<a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a>&nbsp;→ <em>Password &amp; Auth</em>.</li><li>In the <em>OpenID Connect</em> section, press the <em>Disconnect</em> (<span class=\"tn-icon bx bx-trash\"></span>) button.</li><li>Wait for the section to indicate that you are disconnected.</li><li>Change the configuration pointing to the new provider.</li><li>Restart your server.</li><li>Repeat the normal steps to connect to the authentication provider.</li></ol><p>Failing to disconnect before switching providers might temporarily lock you in, as you will not be able to login (credentials won't match). Should this happen:</p><ol><li>Modify the server configuration again to your old provider.</li><li>Restart the server and follow the disconnect instructions above.</li><li>Modify the server configuration again to your new provider.</li><li>Restart again the server.</li></ol><h2>Deactivating OpenID Connect temporarily</h2><p>To disable the OpenID Connect authentication and instead rely on the local password temporarily, you must:</p><ol><li>Modify the <code>config.ini</code> or environment variables (depending on how you set up the provider information) and temporarily deactivate the multi-factor authentication section by renaming <code>[MultiFactorAuthentication]</code> to something else (e.g. <code>[MultiFactorAuthentication.bak]</code>.</li><li>Restart the server for the changes to take effect.</li></ol><h2>Troubleshooting</h2><h3>Setup fails with a <code>WWW-Authenticate</code> or <code>invalid_client</code> error</h3><p>Your provider disagrees with Trilium about how client credentials should be sent to the token endpoint. Set <code>oauthClientAuthMethod</code> to <code>client_secret_post</code> (or <code>client_secret_basic</code> if it's already set to post) and restart. Providers vary: some reject <code>client_secret_post</code> outright because the method is fixed when the client is registered (e.g. Authelia), so if one value doesn't work, try the other.</p><h3>Setup fails with <code>invalid user</code></h3><p>If you are running behind a <a href=\"#root/_help_vcjrb3VVYPZI\">reverse proxy</a>, a buffer overflow can also cause this issue. Here is a sample fix for&nbsp;<a class=\"reference-link\" href=\"#root/_help_ud6MShXL4WpO\">Nginx</a>: </p><pre><code class=\"language-text-x-trilium-auto\">proxy_buffer_size 128k;\nproxy_buffers 4 256k;\nproxy_busy_buffers_size 256k;</code></pre><h3>Setup fails with an <code>unexpected JWT alg</code> error</h3><p>Depending on your version the message reads <code>unexpected JWT \"alg\" header parameter</code> or <code>unexpected JWT alg received, expected RS256, got: EdDSA</code>. Both mean the same thing: your provider signs ID tokens with an algorithm other than RS256. Pocket ID (Ed25519) and Kanidm (ES256) do this.</p><p>From v0.104.2 Trilium detects the algorithm from your provider automatically, and the log records the outcome (<code>OAuth: the issuer does not sign ID tokens with RS256; expecting ES256</code>). If detection can't reach the provider it falls back to RS256, so check that the issuer URL is correct and reachable first. Should it still fail, set <code>oauthIdTokenSigningAlg</code> explicitly to the algorithm your provider uses.</p><h3>Setup fails with <code>OAUTH_RESPONSE_IS_NOT_CONFORM</code></h3><p>Make sure the base URL is correct and that the identity provider actually supports OpenID Connect. Some providers such as GitHub offer only OAuth 2.0.</p>",
"_help_IgkTHSaFfq6A": "<p>This page contains instructions on how to set up&nbsp;<a class=\"reference-link\" href=\"#root/_help_x1lQNKQBqLcA\">Signing in with OpenID Connect</a>&nbsp;with various providers such as Authelia, GitLab, Google.</p><aside class=\"admonition note\"><p>While the configuration reference is correct and up to date, the steps to create the OAuth application might differ slightly as providers change their UI.</p></aside><div class=\"trilium-tabs\"><section class=\"trilium-tab\"><p class=\"trilium-tab-title\">Authelia</p><div class=\"trilium-tab-panel\"><ol><li><p>Generate a client secret:</p><pre><code class=\"language-text-x-trilium-auto\">authelia crypto hash generate pbkdf2 --variant sha512 --random --random.length 72 --random.charset rfc3986\n</code></pre><p><code>Random Password</code> goes to Trilium, <code>Digest</code> (the <code>$pbkdf2-sha512$…</code> string) goes to Authelia.</p></li><li><p>Add a client under <code>identity_providers.oidc.clients</code> in Authelia's <code>configuration.yml</code>, replacing <code>&lt;server&gt;</code> with the URL of your Trilium instance:</p><pre><code class=\"language-text-x-yaml\">identity_providers:\n oidc:\n clients:\n - client_id: 'trilium'\n client_name: 'Trilium'\n client_secret: '&lt;Digest&gt;'\n public: false\n authorization_policy: 'two_factor'\n redirect_uris:\n - 'https://&lt;server&gt;/callback'\n scopes:\n - 'openid'\n - 'profile'\n - 'email'</code></pre><p>Unlike GitLab, <code>client_id</code> is a name you choose rather than one the provider generates.</p></li><li><p>Restart Authelia.</p></li></ol><p>Adjust <code>config.ini</code>, using the <code>Random Password</code> from step 1:</p><pre><code class=\"language-text-x-trilium-auto\">[MultiFactorAuthentication]\noauthBaseUrl=https://&lt;server&gt;\noauthClientId=&lt;ClientId&gt;\noauthClientSecret=&lt;RandomPassword&gt;\noauthIssuerBaseUrl=https://&lt;server&gt;\noauthIssuerName=Authelia</code></pre><aside class=\"admonition important\"><p>Do <strong>not</strong> set <code>oauthClientAuthMethod</code> for Authelia. It defaults confidential clients to <code>client_secret_basic</code> and rejects any other method with <code>invalid_client</code>, which is the default Trilium already uses. This is the opposite of the GitLab case below.</p></aside></div></section><section class=\"trilium-tab\"><p class=\"trilium-tab-title\"><span class=\"tn-icon bx bxl-gitlab\"></span>&nbsp;GitLab</p><div class=\"trilium-tab-panel\"><ol><li>Go to user settings on <a href=\"https://gitlab.com/-/user_settings/applications\">gitlab.com</a> or your own self-hosted instance.</li><li>Press <em>Add new application</em>.</li><li>Give it a name (e.g. Trilium).</li><li>Set <em>Redirect URI</em> to <code>https://&lt;server&gt;/callback</code></li><li>Make sure <em>Confidential</em> is checked and <em>Device authorization grant</em> is unchecked.</li><li>Under scopes, check <em>openid</em>, <em>profile</em> and <em>email</em> (they should be near the end).</li><li>Save the application and copy the <em>Application ID</em> and <em>Secret</em>.</li></ol><p>Adjust <code>config.ini</code> as follows, replacing <code>&lt;ApplicationId&gt;</code> and <code>&lt;Secret&gt;</code> with the values from the last step as well as the <code>&lt;server&gt;</code> with a URL to your Trilium instance.</p><pre><code class=\"language-text-x-trilium-auto\">[MultiFactorAuthentication]\noauthBaseUrl=https://&lt;server&gt;\noauthClientId=&lt;ApplicationId&gt;\noauthClientSecret=&lt;Secret&gt;\noauthIssuerBaseUrl=https://gitlab.com\noauthIssuerName=GitLab\noauthClientAuthMethod=client_secret_post\n</code></pre><aside class=\"admonition important\"><p>If you are using a self-hosted instance of GitLab, make sure to also update <code>oauthIssuerBaseUrl</code>, and keep the <code>oauthClientAuthMethod</code> line above.</p><p>GitLab's token endpoint does not decode credentials sent via HTTP Basic, so without <code>oauthClientAuthMethod</code>, sign-in fails with a <code>server responded with a challenge in the WWW-Authenticate HTTP Header</code> error. Trilium applies this automatically for <code>gitlab.com</code>, but a self-hosted issuer URL cannot be detected.</p></aside></div></section><section class=\"trilium-tab\"><p class=\"trilium-tab-title\">Kanidm</p><div class=\"trilium-tab-panel\"><ol><li><p>Create the client, add the redirect URL and grant the scopes, replacing <code>&lt;server&gt;</code> with the URL of your Trilium instance and <code>&lt;group&gt;</code> with an existing Kanidm group whose members may sign in:</p><pre><code class=\"language-text-x-trilium-auto\">kanidm system oauth2 create trilium \"Trilium\" \"https://&lt;server&gt;\"\nkanidm system oauth2 add-redirect-url trilium \"https://&lt;server&gt;/callback\"\nkanidm system oauth2 update-scope-map trilium &lt;group&gt; openid profile email</code></pre><p>The <code>openid</code> scope is mandatory; without it Kanidm treats the client as plain OAuth 2.0.</p></li><li><p>Read the client secret:</p><pre><code class=\"language-text-x-trilium-auto\">kanidm system oauth2 show-basic-secret trilium</code></pre></li></ol><p>Adjust <code>config.ini</code> as follows, replacing <code>&lt;idm&gt;</code> with the URL of your Kanidm instance and <code>&lt;BasicSecret&gt;</code> with the value from step 2:</p><pre><code class=\"language-text-x-trilium-auto\">[MultiFactorAuthentication]\noauthBaseUrl=https://&lt;server&gt;\noauthClientId=trilium\noauthClientSecret=&lt;BasicSecret&gt;\noauthIssuerBaseUrl=https://&lt;idm&gt;/oauth2/openid/trilium\noauthIssuerName=Kanidm</code></pre><p>The client name you chose in step 1 is both the client ID and the last path segment of the issuer URL, so the two must match.</p><aside class=\"admonition important\"><p>Kanidm signs ID tokens with ES256, not RS256. Trilium detects this from the provider on v0.105.0 and later, so no extra configuration is needed. Do <strong>not</strong> run <code>kanidm system oauth2 warning-enable-legacy-crypto</code>, it downgrades the client to RS256 and disables ES256 entirely. On older Trilium versions sign-in fails with an <code>unexpected JWT alg</code> error.</p></aside></div></section><section class=\"trilium-tab\"><p class=\"trilium-tab-title\">Pocket ID</p><div class=\"trilium-tab-panel\"><aside class=\"admonition important\"><p>Pocket ID is passwordless, signing in requires a passkey. Register one and confirm you can sign in to Pocket ID itself <em>before</em> switching Trilium over to OpenID Connect, otherwise you may find yourself unable to authenticate at either end.</p></aside><ol><li>Sign in to Pocket ID as an administrator and go to <em>OIDC Clients</em> → <em>Add OIDC Client</em>.</li><li>Give it a name (e.g. Trilium).</li><li>Set <em>Callback URLs</em> to <code>https://&lt;server&gt;/callback</code>, replacing <code>&lt;server&gt;</code> with the URL of your Trilium instance.</li><li>Save, then copy the <em>Client ID</em>, <em>Client Secret</em> and <em>OIDC Discovery URL</em>.</li></ol><p>Adjust <code>config.ini</code> as follows, using the values from step 4:</p><pre><code class=\"language-text-x-trilium-auto\">[MultiFactorAuthentication]\noauthBaseUrl=https://&lt;server&gt;\noauthClientId=&lt;ClientID&gt;\noauthClientSecret=&lt;ClientSecret&gt;\noauthIssuerBaseUrl=&lt;OIDCDiscoveryURL&gt;\noauthIssuerName=Pocket ID</code></pre><aside class=\"admonition note\"><p>Pocket ID gives you an <em>OIDC Discovery URL</em> ending in <code>/.well-known/openid-configuration</code>. On v0.105.0 and later you can paste it as-is. On earlier versions, remove that suffix and use only the part before it.</p></aside><aside class=\"admonition important\"><p>Pocket ID generates an RS256 signing key on first start, which works without further configuration. If you rotate it to Ed25519 (<code>pocket-id key-rotate --alg EdDSA --crv Ed25519</code>), ID tokens are signed with EdDSA instead. Trilium detects this automatically on v0.105.0 and later; older versions fail with <code>unexpected JWT alg received, expected RS256, got: EdDSA</code>.</p></aside></div></section><section class=\"trilium-tab\"><p class=\"trilium-tab-title\"><span style=\"--tn-color:#e64d4d;color:#e64d4d;\"><span class=\"tn-icon bx bx-x\"></span>&nbsp;GitHub</span></p><div class=\"trilium-tab-panel\"><p>GitHub cannot be used as an identity provider because it is plain OAuth 2.0 and not OpenID Connect, so it will fail with <code>OAUTH_RESPONSE_IS_NOT_CONFORM</code>.</p></div></section><section class=\"trilium-tab\"><p class=\"trilium-tab-title\"><span class=\"tn-icon bx bxl-google\"></span>&nbsp;Google</p><div class=\"trilium-tab-panel\"><ol><li>Go to <a href=\"https://console.cloud.google.com/auth/clients\">Google Cloud's Clients</a> dashboard and select <em>Create client</em>.</li><li>For <em>Application type,</em> select <em>Web application</em>.</li><li>In <em>Authorized redirect URIs</em>, set &nbsp;<code>https://&lt;server&gt;/callback</code>.</li><li>Press <em>Create</em> and copy <em>Client ID</em> and <em>Client secret</em>.</li></ol><p>Adjust <code>config.ini</code> as follows, replacing <code>&lt;ClientID&gt;</code> and <code>&lt;ClientSecret&gt;</code> with the values from the last step as well as the <code>&lt;server&gt;</code> with a URL to your Trilium instance.</p><pre><code class=\"language-text-x-trilium-auto\">[MultiFactorAuthentication]\noauthBaseUrl=https://&lt;server&gt;\noauthClientId=&lt;ClientID&gt;\noauthClientSecret=&lt;ClientSecret&gt;</code></pre></div></section></div>",
"_help_yeEaYqosGLSh": "<p>As an alternative to <a href=\"#root/_help_Dgg7bR3b6K9j\">hosting your own Trilium instance</a>, there are two services out there that provide out of the box support for Trilium.</p><aside class=\"admonition important\"><p><strong>Disclaimer</strong>: The Trilium Notes project and maintainers are not directly affiliated with either of the projects.</p><p>PikaPods have gracefully offered us free credits for testing purposes.</p></aside><h2>Cloud instance providers</h2><h3>PikaPods</h3><ol><li>Go to <a href=\"https://www.pikapods.com\">pikapods.com</a> &nbsp;and sign up.</li><li>In the “Available Apps” section, look for \"TriliumNext<br>&nbsp;and select “Run your own”.</li><li>Follow the on-screen instructions to set up your own cloud hosted instance.</li></ol><p>PikaPods generally updates their Trilium instances to the latest version within a two-week interval after a new version is released.</p><h2>Matching your version with the cloud instance</h2><p>Please note that once you set up&nbsp;<a class=\"reference-link\" href=\"#root/_help_cbkrhQjrkKrh\">Synchronization</a>&nbsp;between a cloud instance and <a href=\"#root/_help_poXkQfguuA0U\">desktop</a> clients, it's important that the version of the desktop application and the server match up.</p><p>When setting up a cloud instance, it's best to check the version of the server by accessing it via a web browser and going to the <em>About</em> section. It's best that both the desktop and the server have the same <em>App version</em>; however it's generally OK to update the desktop to a newer version than the server if it has the same <em>Sync version</em>.</p><p>If the <em>Sync version</em> between the server and the desktop application doesn't match, synchronization will not work.</p>",
@@ -225,7 +225,7 @@
"_help_oyIAJ9PvvwHX": "<p>There are some situations where modifying the SQLite database that Trilium uses is desirable.</p><p>If you are doing any advanced development or troubleshooting where you manually modify the database, you might want to consider creating backups of your <code>document.db</code> file.</p><h2>Modifying it internally using the SQL Console</h2><p>The SQL Console is Trilium's built-in database editor.</p><p>See&nbsp;<a class=\"reference-link\" href=\"#root/_help_YKWqdJhzi2VY\">SQL Console</a>.</p><h2>Externally modifying the database</h2><p>Sometimes the SQL Console cannot be used (for example if the application cannot start).</p><p>When making external modifications, consider closing the desktop application. If modifying the server database, then stop the service or Docker container.</p><h3>Using DB Browser for SQLite</h3><p>DB Browser for SQLite is a cross-platform editor that can be used to alter the database using a graphical user interface.</p><p>To do so:</p><ol><li>In the main menu, select File → Open database… and navigate to the database in the&nbsp;<a href=\"#root/_help_tAassRL4RSQL\">Data directory</a>.</li><li>Select the <em>Execute SQL</em> tab.</li><li>Type in the desired SQL statement.</li><li>Press the \"Play\" button in the toolbar underneath the \"Execute SQL\" tab (or F5 key).</li><li>Press \"Write Changes\" in the main toolbar.</li><li>Close the application or close the database.</li></ol><p><img src=\"{{helpAssets}}/User%20Guide/Advanced%20Usage/Database/Manually%20altering%20the%20database_image.jpg\"></p><h3>Using the SQLite CLI</h3><p>First, start the SQLite 3 CLI by specifying the path to the database:</p><pre><code class=\"language-text-x-trilium-auto\">sqlite3 ~/.local/share/trilium-data/document.db</code></pre><ul><li>In the prompt simply type the statement and make sure it ends with a <code>;</code> character.</li><li>To exit, simply type <code>.quit</code> and enter.</li></ul>",
"_help_YKWqdJhzi2VY": "<aside class=\"admonition important\"><p>Starting with v0.104.0, backend scripts are disabled by default to reduce the attack surface. See&nbsp;<a class=\"reference-link\" href=\"#root/_help_fiHicjpHjIRJ\">Security</a>&nbsp;for more information.</p></aside><p>The SQL Console is Trilium's built-in database editor.</p><p>It can be accessed by going to the&nbsp;<a class=\"reference-link\" href=\"#root/_help_x3i7MxGccDuM\">Global menu</a>&nbsp;→ Advanced → Open SQL Console.</p><p><img src=\"{{helpAssets}}/User%20Guide/Advanced%20Usage/Database/Manually%20altering%20the%20database/SQL%20Console_image.jpg\"></p><h3>Interaction</h3><ul><li>Hovering the mouse over one of the tables listed at the top of the document will show the columns and their data type.</li><li>Only one SQL statement can be run at once.</li><li>To run the statement, press the <em>Execute</em> icon.</li><li>For queries that return a result, the data will displayed in a table.</li><li>For statements (e.g. <code>INSERT</code>, <code>UPDATE</code>), the number of affected rows is displayed.</li></ul><figure class=\"image\"><img style=\"aspect-ratio:1124/571;\" src=\"{{helpAssets}}/User%20Guide/Advanced%20Usage/Database/Manually%20altering%20the%20database/SQL%20Console_image.png\" width=\"1124\" height=\"571\"></figure><h3>Interacting with the table</h3><p>After executing a query, a table with the results will be displayed:</p><ul><li>Clicking on a column allows sorting ascending or descending.</li><li>Underneath each column there is an input field which allows filtering by text.</li><li>Press <kbd>Ctrl</kbd>+<kbd>C</kbd> to copy the current cell to clipboard.</li><li>Multiple cells can be selected by dragging or by holding <kbd>Shift</kbd> + arrow keys</li><li>Results are paginated for performance reasons. The controls at the bottom of the table can be used to navigate through pages.</li></ul><h3>Saved SQL console</h3><p>SQL queries or commands can be saved into a dedicated note.</p><p>To do so, simply write the query and press the&nbsp;<span class=\"tn-icon bx bx-save\"></span> button. Once saved, the note will appear in&nbsp;<a class=\"reference-link\" href=\"#root/_help_l0tKav7yLHGF\">Day Notes</a>&nbsp;by default. It is possible to change the default location of saved queries by assigning a <code>#sqlConsoleHome</code> <a href=\"#root/_help_HI6GBBIduIgv\">label</a>.</p><p>The note can be locked for editing by pressing the <em>Lock</em> button in the note actions section near the title bar. When editing is locked, the SQL statement is hidden from view.</p>",
"_help_6tZeKvSHEUiB": "<p>When you run Trilium for the first time, it will generate a new database containing demo notes. These notes showcase its many features, such as:</p><ul><li><a class=\"reference-link\" href=\"#root/_help_iRwzGnHPzonm\">Relation Map</a></li><li><a class=\"reference-link\" href=\"#root/_help_l0tKav7yLHGF\">Day Notes</a></li><li><a class=\"reference-link\" href=\"#root/_help_R7abl2fc6Mxi\">Weight Tracker</a></li><li><a class=\"reference-link\" href=\"#root/_help_xYjQUYhpbUEW\">Task Manager</a></li><li><a class=\"reference-link\" href=\"#root/_help_Wy267RK4M69c\">Themes</a></li></ul><h3>Restoring Demo Notes</h3><p>There are some cases in which you may want to restore the original demo notes. For example, if you experimented with some of the more advanced features and want to see the original reference, or if you simply want to explore the latest version of the demo notes, which might showcase new features.</p><p>You can easily restore the demo notes by using Trilium's built-in import feature by importing them:</p><ul><li>Download <a href=\"https://github.com/TriliumNext/Trilium/raw/refs/heads/main/apps/server/src/assets/db/demo.zip\">the .zip archive</a> with the latest version of the demo notes</li><li>Right click on any note in your tree under which you would like the demo notes to be imported</li><li>Click \"Import into note…\"</li><li>Select the .zip archive to import it</li></ul>",
- "_help_Gzjqa934BdH4": "<p>Trilium supports configuration via a file named <code>config.ini</code> and environment variables. This document provides a comprehensive reference for all configuration options.</p><h2>Location of the configuration file</h2><p>The configuration file is not located in the same directory as the application. Instead, the <code>config.ini</code> is located in the&nbsp;<a class=\"reference-link\" href=\"#root/_help_tAassRL4RSQL\">Data directory</a>. As such, the configuration file is only available after starting the application and creating a database.</p><h2>Configuration Precedence</h2><p>Configuration values are loaded in the following order of precedence (highest to lowest):</p><ol><li><strong>Environment variables</strong> (checked first)</li><li><strong>config.ini file values</strong></li><li><strong>Default values</strong></li></ol><h2>Environment Variable Patterns</h2><p>Trilium supports multiple environment variable patterns for flexibility. The primary pattern is: <code>TRILIUM_[SECTION]_[KEY]</code></p><p>Where:</p><ul><li><code>SECTION</code> is the INI section name in UPPERCASE</li><li><code>KEY</code> is the camelCase configuration key converted to UPPERCASE (e.g., <code>instanceName</code> → <code>INSTANCENAME</code>)</li></ul><p>Additionally, shorter aliases are available for common configurations (see Alternative Variables section below).</p><h2>Environment Variable Reference</h2><div class=\"trilium-tabs\"><section class=\"trilium-tab\"><p class=\"trilium-tab-title\">General</p><div class=\"trilium-tab-panel\"><figure class=\"table\"><table><thead><tr><th>Environment Variable</th><th>Type</th><th>Default</th><th>Description</th></tr></thead><tbody><tr><td><code>TRILIUM_GENERAL_INSTANCENAME</code></td><td>string</td><td>\"\"</td><td>Instance name for API identification</td></tr><tr><td><code>TRILIUM_GENERAL_NOAUTHENTICATION</code></td><td>boolean</td><td>false</td><td>Disable authentication (server only)</td></tr><tr><td><code>TRILIUM_GENERAL_NOBACKUP</code></td><td>boolean</td><td>false</td><td>Disable automatic backups</td></tr><tr><td><code>TRILIUM_GENERAL_NODESKTOPICON</code></td><td>boolean</td><td>false</td><td>Disable desktop icon creation</td></tr><tr><td><code>TRILIUM_GENERAL_READONLY</code></td><td>boolean</td><td>false</td><td>Enable read-only mode</td></tr></tbody></table></figure></div></section><section class=\"trilium-tab\"><p class=\"trilium-tab-title\">Network</p><div class=\"trilium-tab-panel\"><figure class=\"table\"><table><thead><tr><th>Environment Variable</th><th>Type</th><th>Default</th><th>Description</th></tr></thead><tbody><tr><td><code>TRILIUM_NETWORK_HOST</code></td><td>string</td><td>\"0.0.0.0\"</td><td>Server host binding</td></tr><tr><td><code>TRILIUM_NETWORK_PORT</code></td><td>string</td><td>\"8080\"</td><td>Server port</td></tr><tr><td><code>TRILIUM_NETWORK_HTTPS</code></td><td>boolean</td><td>false</td><td>Enable HTTPS</td></tr><tr><td><code>TRILIUM_NETWORK_CERTPATH</code></td><td>string</td><td>\"\"</td><td>SSL certificate path</td></tr><tr><td><code>TRILIUM_NETWORK_KEYPATH</code></td><td>string</td><td>\"\"</td><td>SSL key path</td></tr><tr><td><code>TRILIUM_NETWORK_TRUSTEDREVERSEPROXY</code></td><td>boolean/string</td><td>false</td><td>Reverse proxy trust settings</td></tr><tr><td><code>TRILIUM_NETWORK_CORSALLOWORIGIN</code></td><td>string</td><td>\"\"</td><td>CORS allowed origins</td></tr><tr><td><code>TRILIUM_NETWORK_CORSALLOWMETHODS</code></td><td>string</td><td>\"\"</td><td>CORS allowed methods</td></tr><tr><td><code>TRILIUM_NETWORK_CORSALLOWHEADERS</code></td><td>string</td><td>\"\"</td><td>CORS allowed headers</td></tr><tr><td><code>TRILIUM_NETWORK_CORSRESOURCEPOLICY</code></td><td>string</td><td>same-origin</td><td>CORS Resource Policy allows same-origin/same-site/cross-origin as values, will error if not</td></tr></tbody></table></figure></div></section><section class=\"trilium-tab\"><p class=\"trilium-tab-title\">Session</p><div class=\"trilium-tab-panel\"><figure class=\"table\"><table><thead><tr><th>Environment Variable</th><th>Type</th><th>Default</th><th>Description</th></tr></thead><tbody><tr><td><code>TRILIUM_SESSION_COOKIEMAXAGE</code></td><td>integer</td><td>1814400</td><td>Session cookie max age in seconds (21 days)</td></tr></tbody></table></figure></div></section><section class=\"trilium-tab\"><p class=\"trilium-tab-title\">Sync</p><div class=\"trilium-tab-panel\"><figure class=\"table\"><table><thead><tr><th>Environment Variable</th><th>Type</th><th>Default</th><th>Description</th></tr></thead><tbody><tr><td><code>TRILIUM_SYNC_SYNCSERVERHOST</code></td><td>string</td><td>\"\"</td><td>Sync server host URL</td></tr><tr><td><code>TRILIUM_SYNC_SYNCSERVERTIMEOUT</code></td><td>string</td><td>\"120000\"</td><td>Sync server timeout in milliseconds</td></tr><tr><td><code>TRILIUM_SYNC_SYNCPROXY</code></td><td>string</td><td>\"\"</td><td>Sync proxy URL</td></tr></tbody></table></figure></div></section><section class=\"trilium-tab\"><p class=\"trilium-tab-title\">MultiFactorAuthentication</p><div class=\"trilium-tab-panel\"><p>See&nbsp;<a class=\"reference-link\" href=\"#root/_help_x1lQNKQBqLcA\">Signing in with OpenID Connect</a>.</p></div></section><section class=\"trilium-tab\"><p class=\"trilium-tab-title\">Logging</p><div class=\"trilium-tab-panel\"><figure class=\"table\"><table><thead><tr><th>Environment Variable</th><th>Type</th><th>Default</th><th>Description</th></tr></thead><tbody><tr><td><code>TRILIUM_LOGGING_RETENTIONDAYS</code></td><td>integer</td><td>90</td><td>Number of days to retain log files</td></tr></tbody></table></figure></div></section><section class=\"trilium-tab\"><p class=\"trilium-tab-title\">Development</p><div class=\"trilium-tab-panel\"><figure class=\"table\"><table><thead><tr><th>Environment Variable</th><th>Type</th><th>Default</th><th>Description</th></tr></thead><tbody><tr><td><code>TRILIUM_MANUAL_DB_MIGRATION</code></td><td>boolean</td><td>false</td><td>If <code>true</code>, the application will not start if automatic database migrations are pending and would modify the database schema.</td></tr></tbody></table></figure></div></section></div><details class=\"trilium-collapsible\"><summary>Alternative environment variables</summary><p>The following alternative environment variable names are also supported and work identically to their longer counterparts.</p><div class=\"trilium-tabs\"><section class=\"trilium-tab\"><p class=\"trilium-tab-title\">Network CORS</p><div class=\"trilium-tab-panel\"><ul><li><code>TRILIUM_NETWORK_CORS_ALLOW_ORIGIN</code> (alternative to <code>TRILIUM_NETWORK_CORSALLOWORIGIN</code>)</li><li><code>TRILIUM_NETWORK_CORS_ALLOW_METHODS</code> (alternative to <code>TRILIUM_NETWORK_CORSALLOWMETHODS</code>)</li><li><code>TRILIUM_NETWORK_CORS_ALLOW_HEADERS</code> (alternative to <code>TRILIUM_NETWORK_CORSALLOWHEADERS</code>)</li><li><code>TRILIUM_NETWORK_CORS_RESOURCE_POLICY</code> (alternative to <code>TRILIUM_NETWORK_CORSRESOURCEPOLICY</code>)</li></ul></div></section><section class=\"trilium-tab\"><p class=\"trilium-tab-title\">Sync</p><div class=\"trilium-tab-panel\"><ul><li><code>TRILIUM_SYNC_SERVER_HOST</code> (alternative to <code>TRILIUM_SYNC_SYNCSERVERHOST</code>)</li><li><code>TRILIUM_SYNC_SERVER_TIMEOUT</code> (alternative to <code>TRILIUM_SYNC_SYNCSERVERTIMEOUT</code>)</li><li><code>TRILIUM_SYNC_SERVER_PROXY</code> (alternative to <code>TRILIUM_SYNC_SYNCPROXY</code>)</li></ul></div></section><section class=\"trilium-tab\"><p class=\"trilium-tab-title\">OAuth/MFA</p><div class=\"trilium-tab-panel\"><ul><li><code>TRILIUM_OAUTH_BASE_URL</code> (alternative to <code>TRILIUM_MULTIFACTORAUTHENTICATION_OAUTHBASEURL</code>)</li><li><code>TRILIUM_OAUTH_CLIENT_ID</code> (alternative to <code>TRILIUM_MULTIFACTORAUTHENTICATION_OAUTHCLIENTID</code>)</li><li><code>TRILIUM_OAUTH_CLIENT_SECRET</code> (alternative to <code>TRILIUM_MULTIFACTORAUTHENTICATION_OAUTHCLIENTSECRET</code>)</li><li><code>TRILIUM_OAUTH_ISSUER_BASE_URL</code> (alternative to <code>TRILIUM_MULTIFACTORAUTHENTICATION_OAUTHISSUERBASEURL</code>)</li><li><code>TRILIUM_OAUTH_ISSUER_NAME</code> (alternative to <code>TRILIUM_MULTIFACTORAUTHENTICATION_OAUTHISSUERNAME</code>)</li><li><code>TRILIUM_OAUTH_ISSUER_ICON</code> (alternative to <code>TRILIUM_MULTIFACTORAUTHENTICATION_OAUTHISSUERICON</code>)</li><li><code>TRILIUM_OAUTH_HTTP_TIMEOUT</code> (alternative to <code>TRILIUM_MULTIFACTORAUTHENTICATION_OAUTHHTTPTIMEOUT</code>)</li><li><code>TRILIUM_OAUTH_SCOPE</code> (alternative to <code>TRILIUM_MULTIFACTORAUTHENTICATION_OAUTHSCOPE</code>)</li></ul></div></section><section class=\"trilium-tab\"><p class=\"trilium-tab-title\">Logging</p><div class=\"trilium-tab-panel\"><ul><li><code>TRILIUM_LOGGING_RETENTION_DAYS</code> (alternative to <code>TRILIUM_LOGGING_RETENTIONDAYS</code>)</li></ul></div></section></div></details><h2>Boolean Values</h2><p>Boolean environment variables accept the following values:</p><ul><li><strong>True</strong>: <code>\"true\"</code>, <code>\"1\"</code>, <code>1</code></li><li><strong>False</strong>: <code>\"false\"</code>, <code>\"0\"</code>, <code>0</code></li><li>Any other value defaults to <code>false</code></li></ul><h2>Using Environment Variables</h2><p>Both naming patterns are fully supported and can be used interchangeably:</p><ul><li>The longer format follows the section/key pattern for consistency with the INI file structure</li><li>The shorter alternatives provide convenience for common configurations</li><li>You can use whichever format you prefer - both are equally valid</li></ul><h2>Examples</h2><div class=\"trilium-tabs\"><section class=\"trilium-tab\"><p class=\"trilium-tab-title\"><span class=\"tn-icon bx bxl-docker\"></span>&nbsp;Docker Compose</p><div class=\"trilium-tab-panel\"><pre><code class=\"language-text-x-yaml\">services:\n trilium:\n image: triliumnext/trilium\n environment:\n # Using full format\n TRILIUM_GENERAL_INSTANCENAME: \"My Trilium Instance\"\n TRILIUM_NETWORK_PORT: \"8080\"\n TRILIUM_NETWORK_CORSALLOWORIGIN: \"https://myapp.com\"\n TRILIUM_SYNC_SYNCSERVERHOST: \"https://sync.example.com\"\n TRILIUM_MULTIFACTORAUTHENTICATION_OAUTHBASEURL: \"https://auth.example.com\"\n \n # Or using shorter alternatives (equally valid)\n # TRILIUM_NETWORK_CORS_ALLOW_ORIGIN: \"https://myapp.com\"\n # TRILIUM_SYNC_SERVER_HOST: \"https://sync.example.com\"\n # TRILIUM_OAUTH_BASE_URL: \"https://auth.example.com\"</code></pre></div></section><section class=\"trilium-tab\"><p class=\"trilium-tab-title\"><span class=\"tn-icon bx bxl-tux\"></span>&nbsp;Linux Shell</p><div class=\"trilium-tab-panel\"><pre><code class=\"language-text-x-trilium-auto\"># Using either format\nexport TRILIUM_GENERAL_NOAUTHENTICATION=false\nexport TRILIUM_NETWORK_HTTPS=true\nexport TRILIUM_NETWORK_CERTPATH=/path/to/cert.pem\nexport TRILIUM_NETWORK_KEYPATH=/path/to/key.pem\nexport TRILIUM_LOGGING_RETENTIONDAYS=30\n\n# Start Trilium\nnpm start</code></pre></div></section></div><h2>config.ini Reference</h2><p>For the complete list of configuration options and their INI file format, please review the <a href=\"https://github.com/TriliumNext/Trilium/blob/main/apps/server/src/assets/config-sample.ini\">config-sample.ini</a> file in the Trilium repository.</p>",
+ "_help_Gzjqa934BdH4": "<p>Trilium supports configuration via a file named <code>config.ini</code> and environment variables. This document provides a comprehensive reference for all configuration options.</p><h2>Location of the configuration file</h2><p>The configuration file is not located in the same directory as the application. Instead, the <code>config.ini</code> is located in the&nbsp;<a class=\"reference-link\" href=\"#root/_help_tAassRL4RSQL\">Data directory</a>. As such, the configuration file is only available after starting the application and creating a database.</p><h2>Configuration Precedence</h2><p>Configuration values are loaded in the following order of precedence (highest to lowest):</p><ol><li><strong>Environment variables</strong> (checked first)</li><li><strong>config.ini file values</strong></li><li><strong>Default values</strong></li></ol><h2>Environment Variable Patterns</h2><p>Trilium supports multiple environment variable patterns for flexibility. The primary pattern is: <code>TRILIUM_[SECTION]_[KEY]</code></p><p>Where:</p><ul><li><code>SECTION</code> is the INI section name in UPPERCASE</li><li><code>KEY</code> is the camelCase configuration key converted to UPPERCASE (e.g., <code>instanceName</code> → <code>INSTANCENAME</code>)</li></ul><p>Additionally, shorter aliases are available for common configurations (see Alternative Variables section below).</p><h2>Environment Variable Reference</h2><div class=\"trilium-tabs\"><section class=\"trilium-tab\"><p class=\"trilium-tab-title\">General</p><div class=\"trilium-tab-panel\"><figure class=\"table\"><table><thead><tr><th>Environment Variable</th><th>Type</th><th>Default</th><th>Description</th></tr></thead><tbody><tr><td><code>TRILIUM_GENERAL_INSTANCENAME</code></td><td>string</td><td>\"\"</td><td>Instance name for API identification</td></tr><tr><td><code>TRILIUM_GENERAL_NOAUTHENTICATION</code></td><td>boolean</td><td>false</td><td>Disable authentication (server only)</td></tr><tr><td><code>TRILIUM_GENERAL_NOBACKUP</code></td><td>boolean</td><td>false</td><td>Disable automatic backups</td></tr><tr><td><code>TRILIUM_GENERAL_NODESKTOPICON</code></td><td>boolean</td><td>false</td><td>Disable desktop icon creation</td></tr><tr><td><code>TRILIUM_GENERAL_READONLY</code></td><td>boolean</td><td>false</td><td>Enable read-only mode</td></tr></tbody></table></figure></div></section><section class=\"trilium-tab\"><p class=\"trilium-tab-title\">Network</p><div class=\"trilium-tab-panel\"><figure class=\"table\"><table><thead><tr><th>Environment Variable</th><th>Type</th><th>Default</th><th>Description</th></tr></thead><tbody><tr><td><code>TRILIUM_NETWORK_HOST</code></td><td>string</td><td>\"0.0.0.0\"</td><td>Server host binding</td></tr><tr><td><code>TRILIUM_NETWORK_PORT</code></td><td>string</td><td>\"8080\"</td><td>Server port</td></tr><tr><td><code>TRILIUM_NETWORK_HTTPS</code></td><td>boolean</td><td>false</td><td>Enable HTTPS</td></tr><tr><td><code>TRILIUM_NETWORK_CERTPATH</code></td><td>string</td><td>\"\"</td><td>SSL certificate path</td></tr><tr><td><code>TRILIUM_NETWORK_KEYPATH</code></td><td>string</td><td>\"\"</td><td>SSL key path</td></tr><tr><td><code>TRILIUM_NETWORK_TRUSTEDREVERSEPROXY</code></td><td>string</td><td>false</td><td>Addresses of the reverse proxy to trust, see <a href=\"#root/_help_LLzSMXACKhUs\">Trusted proxy</a></td></tr><tr><td><code>TRILIUM_NETWORK_CORSALLOWORIGIN</code></td><td>string</td><td>\"\"</td><td>CORS allowed origins</td></tr><tr><td><code>TRILIUM_NETWORK_CORSALLOWMETHODS</code></td><td>string</td><td>\"\"</td><td>CORS allowed methods</td></tr><tr><td><code>TRILIUM_NETWORK_CORSALLOWHEADERS</code></td><td>string</td><td>\"\"</td><td>CORS allowed headers</td></tr><tr><td><code>TRILIUM_NETWORK_CORSRESOURCEPOLICY</code></td><td>string</td><td>same-origin</td><td>CORS Resource Policy allows same-origin/same-site/cross-origin as values, will error if not</td></tr></tbody></table></figure></div></section><section class=\"trilium-tab\"><p class=\"trilium-tab-title\">Session</p><div class=\"trilium-tab-panel\"><figure class=\"table\"><table><thead><tr><th>Environment Variable</th><th>Type</th><th>Default</th><th>Description</th></tr></thead><tbody><tr><td><code>TRILIUM_SESSION_COOKIEMAXAGE</code></td><td>integer</td><td>1814400</td><td>Session cookie max age in seconds (21 days)</td></tr></tbody></table></figure></div></section><section class=\"trilium-tab\"><p class=\"trilium-tab-title\">Sync</p><div class=\"trilium-tab-panel\"><figure class=\"table\"><table><thead><tr><th>Environment Variable</th><th>Type</th><th>Default</th><th>Description</th></tr></thead><tbody><tr><td><code>TRILIUM_SYNC_SYNCSERVERHOST</code></td><td>string</td><td>\"\"</td><td>Sync server host URL</td></tr><tr><td><code>TRILIUM_SYNC_SYNCSERVERTIMEOUT</code></td><td>string</td><td>\"120000\"</td><td>Sync server timeout in milliseconds</td></tr><tr><td><code>TRILIUM_SYNC_SYNCPROXY</code></td><td>string</td><td>\"\"</td><td>Sync proxy URL</td></tr></tbody></table></figure></div></section><section class=\"trilium-tab\"><p class=\"trilium-tab-title\">MultiFactorAuthentication</p><div class=\"trilium-tab-panel\"><p>See&nbsp;<a class=\"reference-link\" href=\"#root/_help_x1lQNKQBqLcA\">Signing in with OpenID Connect</a>.</p></div></section><section class=\"trilium-tab\"><p class=\"trilium-tab-title\">Logging</p><div class=\"trilium-tab-panel\"><figure class=\"table\"><table><thead><tr><th>Environment Variable</th><th>Type</th><th>Default</th><th>Description</th></tr></thead><tbody><tr><td><code>TRILIUM_LOGGING_RETENTIONDAYS</code></td><td>integer</td><td>90</td><td>Number of days to retain log files</td></tr></tbody></table></figure></div></section><section class=\"trilium-tab\"><p class=\"trilium-tab-title\">Development</p><div class=\"trilium-tab-panel\"><figure class=\"table\"><table><thead><tr><th>Environment Variable</th><th>Type</th><th>Default</th><th>Description</th></tr></thead><tbody><tr><td><code>TRILIUM_MANUAL_DB_MIGRATION</code></td><td>boolean</td><td>false</td><td>If <code>true</code>, the application will not start if automatic database migrations are pending and would modify the database schema.</td></tr></tbody></table></figure></div></section></div><details class=\"trilium-collapsible\"><summary>Alternative environment variables</summary><p>The following alternative environment variable names are also supported and work identically to their longer counterparts.</p><div class=\"trilium-tabs\"><section class=\"trilium-tab\"><p class=\"trilium-tab-title\">Network CORS</p><div class=\"trilium-tab-panel\"><ul><li><code>TRILIUM_NETWORK_CORS_ALLOW_ORIGIN</code> (alternative to <code>TRILIUM_NETWORK_CORSALLOWORIGIN</code>)</li><li><code>TRILIUM_NETWORK_CORS_ALLOW_METHODS</code> (alternative to <code>TRILIUM_NETWORK_CORSALLOWMETHODS</code>)</li><li><code>TRILIUM_NETWORK_CORS_ALLOW_HEADERS</code> (alternative to <code>TRILIUM_NETWORK_CORSALLOWHEADERS</code>)</li><li><code>TRILIUM_NETWORK_CORS_RESOURCE_POLICY</code> (alternative to <code>TRILIUM_NETWORK_CORSRESOURCEPOLICY</code>)</li></ul></div></section><section class=\"trilium-tab\"><p class=\"trilium-tab-title\">Sync</p><div class=\"trilium-tab-panel\"><ul><li><code>TRILIUM_SYNC_SERVER_HOST</code> (alternative to <code>TRILIUM_SYNC_SYNCSERVERHOST</code>)</li><li><code>TRILIUM_SYNC_SERVER_TIMEOUT</code> (alternative to <code>TRILIUM_SYNC_SYNCSERVERTIMEOUT</code>)</li><li><code>TRILIUM_SYNC_SERVER_PROXY</code> (alternative to <code>TRILIUM_SYNC_SYNCPROXY</code>)</li></ul></div></section><section class=\"trilium-tab\"><p class=\"trilium-tab-title\">OAuth/MFA</p><div class=\"trilium-tab-panel\"><ul><li><code>TRILIUM_OAUTH_BASE_URL</code> (alternative to <code>TRILIUM_MULTIFACTORAUTHENTICATION_OAUTHBASEURL</code>)</li><li><code>TRILIUM_OAUTH_CLIENT_ID</code> (alternative to <code>TRILIUM_MULTIFACTORAUTHENTICATION_OAUTHCLIENTID</code>)</li><li><code>TRILIUM_OAUTH_CLIENT_SECRET</code> (alternative to <code>TRILIUM_MULTIFACTORAUTHENTICATION_OAUTHCLIENTSECRET</code>)</li><li><code>TRILIUM_OAUTH_ISSUER_BASE_URL</code> (alternative to <code>TRILIUM_MULTIFACTORAUTHENTICATION_OAUTHISSUERBASEURL</code>)</li><li><code>TRILIUM_OAUTH_ISSUER_NAME</code> (alternative to <code>TRILIUM_MULTIFACTORAUTHENTICATION_OAUTHISSUERNAME</code>)</li><li><code>TRILIUM_OAUTH_ISSUER_ICON</code> (alternative to <code>TRILIUM_MULTIFACTORAUTHENTICATION_OAUTHISSUERICON</code>)</li><li><code>TRILIUM_OAUTH_HTTP_TIMEOUT</code> (alternative to <code>TRILIUM_MULTIFACTORAUTHENTICATION_OAUTHHTTPTIMEOUT</code>)</li><li><code>TRILIUM_OAUTH_SCOPE</code> (alternative to <code>TRILIUM_MULTIFACTORAUTHENTICATION_OAUTHSCOPE</code>)</li></ul></div></section><section class=\"trilium-tab\"><p class=\"trilium-tab-title\">Logging</p><div class=\"trilium-tab-panel\"><ul><li><code>TRILIUM_LOGGING_RETENTION_DAYS</code> (alternative to <code>TRILIUM_LOGGING_RETENTIONDAYS</code>)</li></ul></div></section></div></details><h2>Boolean Values</h2><p>Boolean environment variables accept the following values:</p><ul><li><strong>True</strong>: <code>\"true\"</code>, <code>\"1\"</code>, <code>1</code></li><li><strong>False</strong>: <code>\"false\"</code>, <code>\"0\"</code>, <code>0</code></li><li>Any other value defaults to <code>false</code></li></ul><h2>Using Environment Variables</h2><p>Both naming patterns are fully supported and can be used interchangeably:</p><ul><li>The longer format follows the section/key pattern for consistency with the INI file structure</li><li>The shorter alternatives provide convenience for common configurations</li><li>You can use whichever format you prefer - both are equally valid</li></ul><h2>Examples</h2><div class=\"trilium-tabs\"><section class=\"trilium-tab\"><p class=\"trilium-tab-title\"><span class=\"tn-icon bx bxl-docker\"></span>&nbsp;Docker Compose</p><div class=\"trilium-tab-panel\"><pre><code class=\"language-text-x-yaml\">services:\n trilium:\n image: triliumnext/trilium\n environment:\n # Using full format\n TRILIUM_GENERAL_INSTANCENAME: \"My Trilium Instance\"\n TRILIUM_NETWORK_PORT: \"8080\"\n TRILIUM_NETWORK_CORSALLOWORIGIN: \"https://myapp.com\"\n TRILIUM_SYNC_SYNCSERVERHOST: \"https://sync.example.com\"\n TRILIUM_MULTIFACTORAUTHENTICATION_OAUTHBASEURL: \"https://auth.example.com\"\n \n # Or using shorter alternatives (equally valid)\n # TRILIUM_NETWORK_CORS_ALLOW_ORIGIN: \"https://myapp.com\"\n # TRILIUM_SYNC_SERVER_HOST: \"https://sync.example.com\"\n # TRILIUM_OAUTH_BASE_URL: \"https://auth.example.com\"</code></pre></div></section><section class=\"trilium-tab\"><p class=\"trilium-tab-title\"><span class=\"tn-icon bx bxl-tux\"></span>&nbsp;Linux Shell</p><div class=\"trilium-tab-panel\"><pre><code class=\"language-text-x-trilium-auto\"># Using either format\nexport TRILIUM_GENERAL_NOAUTHENTICATION=false\nexport TRILIUM_NETWORK_HTTPS=true\nexport TRILIUM_NETWORK_CERTPATH=/path/to/cert.pem\nexport TRILIUM_NETWORK_KEYPATH=/path/to/key.pem\nexport TRILIUM_LOGGING_RETENTIONDAYS=30\n\n# Start Trilium\nnpm start</code></pre></div></section></div><h2>config.ini Reference</h2><p>For the complete list of configuration options and their INI file format, please review the <a href=\"https://github.com/TriliumNext/Trilium/blob/main/apps/server/src/assets/config-sample.ini\">config-sample.ini</a> file in the Trilium repository.</p>",
"_help_c5xB8m4g2IY6": "<p>A Trilium instance represents a server. If&nbsp;<a class=\"reference-link\" href=\"#root/_help_cbkrhQjrkKrh\">Synchronization</a>&nbsp;is set up, since multiple servers are involved (the one from the desktop client and the one the synchronisation is set up with), sometimes it can be useful to distinguish the instance you are running on.</p><h2>Setting the instance name</h2><p>To set up a name for the instance, modify the <code>config.ini</code>:</p><pre><code class=\"language-text-x-trilium-auto\">[General]\ninstanceName=Hello</code></pre><h2>Distinguishing the instance on back-end</h2><p>Use <code>api.getInstanceName()</code> to obtain the instance name of the current server, as specified in the config file or in environment variables.</p><h2>Limiting script runs based on instance</h2><p>For a script that is run periodically or on a certain event, it's possible to limit it to certain instances without having to change the code. Just add <code>runOnInstance</code> and set as the value the instance name where the script should run. To run on multiple named instances, simply add the label multiple times.</p>",
"_help_LWtBjFej3wX3": "<p>By default, Trilium cannot be accessed in web browsers by requests coming from other domains/origins than Trilium itself.&nbsp;</p><p>However, it is possible to manually configure <a href=\"https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/CORS\">Cross-Origin Resource Sharing (CORS)</a> since Trilium v0.93.0 using environment variables or <code>config.ini</code>, as follows:</p><figure class=\"table\"><table><thead><tr><th>CORS Header</th><th>Corresponding environment variable</th><th>Corresponding option in <code>config.ini</code> variables in the <code>Network</code> section</th></tr></thead><tbody><tr><td><code>Access-Control-Allow-Origin</code></td><td><code>TRILIUM_NETWORK_CORS_ALLOW_ORIGIN</code></td><td><code>corsAllowOrigin</code></td></tr><tr><td><code>Access-Control-Allow-Methods</code></td><td><code>TRILIUM_NETWORK_CORS_ALLOW_METHODS</code></td><td><code>corsAllowMethods</code></td></tr><tr><td><code>Access-Control-Allow-Headers</code></td><td><code>TRILIUM_NETWORK_CORS_ALLOW_HEADERS</code></td><td><code>corsAllowHeaders</code></td></tr></tbody></table></figure>",
"_help_ivYnonVFBxbQ": "<figure class=\"image\"><img style=\"aspect-ratio:1425/644;\" src=\"{{helpAssets}}/User%20Guide/Advanced%20Usage/Bulk%20Actions_image.png\" width=\"1425\" height=\"644\"></figure><p>The <em>Bulk Actions</em> dialog makes it easy to apply changes to multiple notes at once, ranging from simple actions such as adding or removing a label to being executing custom scripts.</p><h2>Interaction</h2><ul><li>The first step is to select the notes in the&nbsp;<a class=\"reference-link\" href=\"#root/_help_oPVyFC7WL2Lp\">Note Tree</a>. It's possible to apply bulk actions to:<ul><li>A single note (and potentially its child notes) simply by clicking on it (with a left click or a right click).</li><li>Multiple notes. See&nbsp;<a class=\"reference-link\" href=\"#root/_help_yTjUdsOi4CIE\">Multiple selection</a>&nbsp;on how to do so.</li></ul></li><li>Right click in the&nbsp;<a class=\"reference-link\" href=\"#root/_help_oPVyFC7WL2Lp\">Note Tree</a>&nbsp;and select <em>Advanced</em> → <em>Apply bulk actions</em>.</li><li>The <em>Selected notes</em> section at the top of the dialog lists the notes the actions apply to. When many notes are selected, only the first few are shown; click <em>+N more</em> to show the rest.<ul><li>To leave a note out without changing the selection in the note tree, press the <span class=\"tn-icon bx bx-x\"></span> button on its entry. The last remaining note cannot be removed.</li></ul></li><li>By default, only the selected notes will be affected. To also include all the descendants of the notes, turn on <em>Include descendants of the selected notes</em>. The number of affected notes, shown below that option, updates to reflect the change.</li><li>To add an action, click <em>Add action</em> (<span class=\"tn-icon bx bx-plus\"></span>) at the bottom of the <em>Chosen actions</em> section and pick one from the menu. Hovering over an entry shows a short description of what it does; a detailed description of each is available in the next section.<ul><li>Each chosen action appears as an entry in the <em>Chosen actions</em> section, with its own configuration.</li><li>To remove an action, simply press the <span class=\"tn-icon bx bx-x\"></span> button to the right of it.</li><li>It is possible to apply multiple actions of the same type, such as adding multiple types.</li><li>The fields for a label or relation name suggest the names already used in the database as you type, marking the ones Trilium itself attaches a meaning to.</li><li>The value field of <em>Add label</em> and <em>Update label value</em> suggests the values the named label already has in the database.</li></ul></li><li>When all the actions are defined, press the <em>Apply to N notes</em> button to trigger all of them at once. The button names the number of notes that will be affected, and stays disabled until at least one action is added.<ul><li>If an action is missing a field it needs, such as the name of the label to rename, the dialog does not run and points out the empty field instead.</li></ul></li><li>For convenience, the last bulk action configuration is saved for further use and will be restored when entering the dialog again.</li></ul><h2>Actions</h2><h3>Labels</h3><p>These actions operate the&nbsp;<a class=\"reference-link\" href=\"#root/_help_HI6GBBIduIgv\">Labels</a>&nbsp;of a note. Except for <em>Add label</em>, they only affect labels set directly on the note; inherited labels are left unchanged.</p><ul><li><strong>Add label</strong><ul><li>For each note, it creates a <a href=\"#root/_help_HI6GBBIduIgv\">label</a> of the given name. Keep the <em>New value</em> field empty to create a label without a value, or complete it to assign a value.</li><li>The label is added even if the note already has one of the same name, so the note ends up with both. To change the value of an existing label instead, use <em>Update label value</em>.</li></ul></li><li><strong>Update label value</strong><ul><li>For each note, if it has a <a href=\"#root/_help_HI6GBBIduIgv\">label</a> of the given name, it will change its value to the specified one. Leave <em>New value</em> field empty to create a label without a value.</li><li>Notes without the label will not be affected.</li></ul></li><li><em><strong>Rename label</strong></em><ul><li>For each note, if it has a <a href=\"#root/_help_HI6GBBIduIgv\">label</a> of the given name, it will be renamed/replaced with a label of the new name. The value of the label (if present) will be kept intact.</li><li>Notes without the label will not be affected.</li></ul></li><li><strong>Delete label</strong><ul><li>For each note, if it has a label of a given name, it will be deleted (regardless of whether it has a value or not).</li><li>Notes without the label will not be affected.</li></ul></li></ul><h3>Relations</h3><p>These actions operate the&nbsp;<a class=\"reference-link\" href=\"#root/_help_Cq5X6iKQop6R\">Relations</a>&nbsp;of a note. Except for <em>Add relation</em>, they only affect relations set directly on the note; inherited relations are left unchanged.</p><ul><li><strong>Add relation</strong><ul><li>For each note, it will create a relation pointing to the given note.</li><li>The relation is added even if the note already has one of the same name.</li></ul></li><li><strong>Update relation target</strong><ul><li>For each note, it will modify a relation to point to the newly given note.</li><li>Notes without this relation will not be affected.</li></ul></li><li><strong>Rename relation</strong><ul><li>For each note, if it has a relation of the given name, it will be renamed/replaced with a relation of the new name. The target note of the relation will be kept intact.</li><li>Notes without this relation will not be affected.</li></ul></li><li><strong>Delete relation</strong><ul><li>For each note, if it has a relation of the given name, it will be deleted.</li><li>Notes without this relation will not be affected.</li></ul></li></ul><h3>Notes</h3><ul><li><strong>Rename note</strong><ul><li>For each note, it will change the title of the note to the given one.</li><li>The title can contain expressions between <code>${</code> and <code>}</code>, which are filled in for each note. They can read the note's properties, such as <code>${note.title}</code>, <code>${note.noteId}</code> or <code>${note.type}</code>, and call <code>getLabelValue('name')</code>, <code>getRelationValue('name')</code> or, on a date such as <code>dateCreatedObj</code>, <code>format('…')</code>. For example:<ul><li><code>NEW: ${note.title}</code> will prefix all notes with <code>NEW:</code> .</li><li><code>${note.dateCreatedObj.format('MM-DD:')}: ${note.title}</code> will prefix the note titles with each note's creation date (in month-day format).</li></ul></li><li>Only property access and those methods are allowed, not arbitrary JavaScript. While typing, the field completes the expressions, underlines one that is not allowed and shows the resulting title for the first selected note.</li></ul></li><li><strong>Move note</strong><ul><li>For each note, it will be moved to the specified parent note.</li><li>A note with several parents is cloned to the new parent instead, since it is not clear which of its places to remove.</li><li>A note that cannot be placed there, such as a parent of the target note, stays where it is.</li><li>As an alternative for less complex situations, the notes can be moved directly from within the&nbsp;<a class=\"reference-link\" href=\"#root/_help_oPVyFC7WL2Lp\">Note Tree</a>&nbsp;via cut → paste or via the contextual menu.</li></ul></li><li><strong>Convert note</strong><ul><li>This allows a note to be converted from one type to another:<ul><li><strong>Text Notes → Markdown Notes</strong> — each&nbsp;<a class=\"reference-link\" href=\"#root/_help_iPIMuisry3hd\">Text</a>&nbsp;note is converted to a&nbsp;<a class=\"reference-link\" href=\"#root/_help_6RM1Q7ppFVoj\">Markdown</a>&nbsp;note. Since Markdown does not support all the formatting capabilities of Text Notes, some formatting may be lost and some unsupported elements may even be dropped.</li><li><strong>Markdown Notes → Text Notes</strong> — each&nbsp;<a class=\"reference-link\" href=\"#root/_help_6RM1Q7ppFVoj\">Markdown</a>&nbsp;note is converted to a&nbsp;<a class=\"reference-link\" href=\"#root/_help_iPIMuisry3hd\">Text</a>&nbsp;Note.</li></ul></li><li>For each converted note, a revision is saved automatically, allowing you to restore the original or recover any missing elements from it.</li></ul></li><li><strong>Save revision</strong><ul><li>Automatically creates a revision of each note. Optionally, a name can be assigned to this revision. See&nbsp;<a class=\"reference-link\" href=\"#root/_help_vZWERwf8U3nx\">Note Revisions</a>.</li></ul></li><li><strong>Delete note</strong><ul><li>For each note, it will be deleted, including all of its clones and any child notes that are not cloned elsewhere.</li><li>Deleted notes can be restored from <em>Recent changes</em> until they are erased.</li><li>As an alternative for less complex situations, the notes can be removed directly from within the&nbsp;<a class=\"reference-link\" href=\"#root/_help_oPVyFC7WL2Lp\">Note Tree</a>&nbsp;by selecting them and pressing <kbd>Delete</kbd>.</li></ul></li><li><strong>Delete note revisions</strong><ul><li>This will permanently erase all the&nbsp;<a class=\"reference-link\" href=\"#root/_help_vZWERwf8U3nx\">Note Revisions</a>&nbsp;of the notes. Unlike deleted notes, erased revisions cannot be restored.</li></ul></li></ul><h3>Others</h3><ul><li><strong>Execute script</strong><ul><li>For more complex scenarios, it is possible to type in a JavaScript expression in order to apply the necessary changes.</li><li>The script runs on the server once for each note, with that note available as <code>note</code> and the backend script API as <code>api</code>. The field completes both as you type and underlines mistakes, as the editor of a backend script note does.</li><li>Examples:<ul><li><p>To apply a suffix (<code>- suffix</code> in this example), to the note title:</p><pre><code class=\"language-text-javascript\">note.title = note.title + \" - suffix\";</code></pre></li><li><p>To alter attributes of a note based on another attribute, such as setting the <code>#shareAlias</code> label to the title of the note:</p><pre><code class=\"language-text-javascript\">note.setLabel(\"shareAlias\", note.title)</code></pre></li></ul></li></ul></li></ul>",
diff --git a/docs/User Guide/User Guide/Advanced Usage/Configuration (config.ini or environment variables).md b/docs/User Guide/User Guide/Advanced Usage/Configuration (config.ini or environment variables).md
index 19f0a98ba1..fc84763700 100644
--- a/docs/User Guide/User Guide/Advanced Usage/Configuration (config.ini or environment variables).md
+++ b/docs/User Guide/User Guide/Advanced Usage/Configuration (config.ini or environment variables).md
@@ -45,7 +45,7 @@ Additionally, shorter aliases are available for common configurations (see Alter
| `TRILIUM_NETWORK_HTTPS` | boolean | false | Enable HTTPS |
| `TRILIUM_NETWORK_CERTPATH` | string | "" | SSL certificate path |
| `TRILIUM_NETWORK_KEYPATH` | string | "" | SSL key path |
- | `TRILIUM_NETWORK_TRUSTEDREVERSEPROXY` | boolean/string | false | Reverse proxy trust settings |
+ | `TRILIUM_NETWORK_TRUSTEDREVERSEPROXY` | string | false | Addresses of the reverse proxy to trust, see [Trusted proxy](../Installation%20%26%20Setup/Server%20Installation/2.%20Reverse%20proxy/Trusted%20proxy.md) |
| `TRILIUM_NETWORK_CORSALLOWORIGIN` | string | "" | CORS allowed origins |
| `TRILIUM_NETWORK_CORSALLOWMETHODS` | string | "" | CORS allowed methods |
| `TRILIUM_NETWORK_CORSALLOWHEADERS` | string | "" | CORS allowed headers |
diff --git a/docs/User Guide/User Guide/Installation & Setup/Server Installation/2. Reverse proxy/Trusted proxy.md b/docs/User Guide/User Guide/Installation & Setup/Server Installation/2. Reverse proxy/Trusted proxy.md
index 954577d0d9..7b5afd3db4 100644
--- a/docs/User Guide/User Guide/Installation & Setup/Server Installation/2. Reverse proxy/Trusted proxy.md
+++ b/docs/User Guide/User Guide/Installation & Setup/Server Installation/2. Reverse proxy/Trusted proxy.md
@@ -1,17 +1,36 @@
# Trusted proxy
-If you are running the Trilium server under a [reverse proxy](../2.%20Reverse%20proxy.md), it's important to configure it as a trusted proxy so that the application can correctly identify the real IP address of the clients (for authentication and rate limiting purposes).
+If you are running the Trilium server under a [reverse proxy](../2.%20Reverse%20proxy.md), it's important to configure it as a trusted proxy so that the application can correctly identify the real IP address of the clients. Trilium uses that address for [brute-force protection](../Authentication.md), for the failed sign-in entries in its logs and to detect whether the connection was made over HTTPS.
-To do so, simply modify <a class="reference-link" href="../../../Advanced%20Usage/Configuration%20(config.ini%20or%20environment%20variables).md">Configuration (config.ini or environment variables)</a> and set:
+Without this setting, every request appears to come from the reverse proxy, so all clients share a single limit of failed sign-in attempts.
+
+## Configuring the trusted proxy
+
+To trust the reverse proxy, modify <a class="reference-link" href="../../../Advanced%20Usage/Configuration%20(config.ini%20or%20environment%20variables).md">Configuration (config.ini or environment variables)</a> and set `trustedReverseProxy` to the address the reverse proxy connects to Trilium from:
```
[Network]
-trustedReverseProxy=true
+trustedReverseProxy=loopback
```
-This will use the left-most IP in the `X-Forwarded-For` header. Alternatively, instead of `true` use the IP address of the reverse proxy or Express.js shortcuts such as:
+The value is a comma-separated list of IP addresses, subnets in CIDR notation or one of the following names:
-```
-loopback(127.0.0.1/8, ::1/128), linklocal(169.254.0.0/16, fe80::/10), uniquelocal(10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16, fc00::/7)
-```
+| Name | Addresses |
+| --- | --- |
+| `loopback` | `127.0.0.1/8`, `::1/128` |
+| `linklocal` | `169.254.0.0/16`, `fe80::/10` |
+| `uniquelocal` | `10.0.0.0/8`, `172.16.0.0/12`, `192.168.0.0/16`, `fc00::/7` |
+
+Trilium then reads the client's address from the `X-Forwarded-For` header, taking the right-most entry that does not belong to a trusted address. Entries a client adds to the header are to the left of the ones the proxy appends, so they are ignored.
+
+Common setups:
+
+* **The reverse proxy runs on the same machine**: use `loopback`.
+* **Trilium runs in Docker, with the reverse proxy on the host or in another container**: use the subnet of the Docker network (for example `172.18.0.0/16`), or `uniquelocal` to cover every Docker network. With the environment variable: `TRILIUM_NETWORK_TRUSTEDREVERSEPROXY=172.18.0.0/16`.
+* **The reverse proxy runs on another machine**: use its IP address.
+
+Only list addresses that the reverse proxy connects from. Any client connecting from a trusted address can claim to be another client through the `X-Forwarded-For` header. This matters for broad values such as `uniquelocal`: if devices on your local network can also reach Trilium directly, use the proxy's exact address instead.
+
+> [!WARNING]
+> Avoid setting `trustedReverseProxy=true`. It makes Trilium use the left-most entry of `X-Forwarded-For`, which is the value the client sent, unless the proxy discards the incoming header. Proxies usually append to it instead (such as Nginx's `$proxy_add_x_forwarded_for`), so a client can send a different address with every request and bypass the limit on failed sign-in attempts.
For more information, consult [Express behind proxies](https://expressjs.com/en/guide/behind-proxies.html).
\ No newline at end of file
diff --git a/docs/User Guide/User Guide/Installation & Setup/Server Installation/Authentication.md b/docs/User Guide/User Guide/Installation & Setup/Server Installation/Authentication.md
index c9bb752fb4..ca4b6a9676 100644
--- a/docs/User Guide/User Guide/Installation & Setup/Server Installation/Authentication.md
+++ b/docs/User Guide/User Guide/Installation & Setup/Server Installation/Authentication.md
@@ -10,6 +10,34 @@ noAuthentication=true
Disabling authentication will bypass even the <a class="reference-link" href="Multi-factor%20authentication%20with%20TOTP.md">Multi-Factor Authentication</a> since v0.94.1.
+## Brute-force protection
+
+Trilium limits each IP address to 10 failed sign-in attempts in 15 minutes. Once an address reaches the limit, Trilium rejects every further attempt from it, including correct ones, until the 15 minutes have passed. The sign-in page then shows _Too many login attempts_; other clients receive HTTP status 429.
+
+The limit applies to every way of signing in with the password:
+
+* The sign-in page.
+* Setting up <a class="reference-link" href="../Synchronization.md">Synchronization</a> from a desktop or mobile app.
+* Connecting the <a class="reference-link" href="../Web%20Clipper.md">Web Clipper</a> or the Android sender app.
+* Requesting a token through <a class="reference-link" href="../../Advanced%20Usage/ETAPI%20(REST%20API).md">ETAPI (REST API)</a>.
+
+All of these count toward the same limit, and a wrong password, a wrong one-time password and a wrong recovery code each count as one failed attempt. Successful sign-ins are not counted.
+
+The limit is per IP address, not per account, so an attacker cannot lock you out by failing to sign in from their own address. The count is kept in memory: restarting the server clears it.
+
+> [!IMPORTANT]
+> Behind a reverse proxy, Trilium sees every request as coming from the proxy unless it is configured as a <a class="reference-link" href="2.%20Reverse%20proxy/Trusted%20proxy.md">Trusted proxy</a>. All clients then share a single limit, so a few wrong attempts from anyone block everyone.
+
+### Blocking repeated failures with fail2ban
+
+A failed attempt on the sign-in page is answered with HTTP status 401 and recorded in the <a class="reference-link" href="../../Troubleshooting/Error%20logs/Backend%20(server)%20logs.md">Backend (server) logs</a> as:
+
+```
+WARNING: Wrong password from 203.0.113.7, rejecting.
+```
+
+When <a class="reference-link" href="Multi-factor%20authentication%20with%20TOTP.md">Multi-Factor Authentication</a> is enabled, a wrong one-time password or recovery code is logged as `Wrong totp` instead. Tools such as fail2ban can match either the log line or the 401 responses to `POST /login` in the reverse proxy's access log to block an address for longer than 15 minutes.
+
## Understanding how the session works
Once logged into Trilium, the application will store this information about the login into a cookie on the browser, but also as a session on the server.
@@ -35,4 +63,5 @@ Expired sessions are periodically cleaned by the server, generally an hourly int
## See also
-* <a class="reference-link" href="Multi-factor%20authentication%20with%20TOTP.md">Multi-Factor Authentication</a>
\ No newline at end of file
+* <a class="reference-link" href="Multi-factor%20authentication%20with%20TOTP.md">Multi-Factor Authentication</a>
+* <a class="reference-link" href="2.%20Reverse%20proxy/Trusted%20proxy.md">Trusted proxy</a>
\ No newline at end of file
diff --git a/docs/User Guide/User Guide/Installation & Setup/Server Installation/Multi-factor authentication with TOTP.md b/docs/User Guide/User Guide/Installation & Setup/Server Installation/Multi-factor authentication with TOTP.md
index 06da0b3882..3be5d5074a 100644
--- a/docs/User Guide/User Guide/Installation & Setup/Server Installation/Multi-factor authentication with TOTP.md
+++ b/docs/User Guide/User Guide/Installation & Setup/Server Installation/Multi-factor authentication with TOTP.md
@@ -17,7 +17,15 @@ TOTP (Time-Based One-Time Password) is a security feature that generates a uniqu
4. Scan the QR code or manually enter the code in your authenticator app.
5. Enter the verification code from your authenticator app to confirm that the setup was successful and press _Verify & continue_.
6. Save the recovery codes, then tick the confirmation and press _Finish setup_.
-7. Re-login will be required after TOTP setup is finished (After you refreshing the page).
+7. Re-login will be required after TOTP setup is finished (after refreshing the page).
+
+## Signing in
+
+Once TOTP is enabled, the sign-in page asks for the code from your authenticator app in _One-time password or recovery code_, below the password.
+
+Trilium accepts the code for the current 30-second period as well as the periods just before and after it, so a clock that is slightly off on either side still works. Since v0.106.0, each code is accepted only once: after a successful sign-in, that code and any older one are rejected, even while they are still valid.
+
+A wrong one-time password counts toward the same limit of failed attempts as a wrong password. See _Brute-force protection_ in <a class="reference-link" href="Authentication.md">Authentication</a>.
## Connecting a device to the server