How to Install Paperless-NGX on Your Synology NAS With MariaDB

How to Install Paperless-NGX on Your Synology NAS With MariaDB

Paperless-ngx is a document management system that transforms your physical documents into a searchable online archive so you can keep, well, less paper. After my article on How to Install Paperless NGX on Your Synology NAS, many people have contacted me asking for a guide that uses MariaDB as a database instead of the default PostgreSQL database. In this step by step guide I will show you how to install Paperless-NGX With MariaDB on your Synology NAS using Docker & Portainer.

💡Note: This guide works perfectly with the latest Paperless-ngx 2.13.5 release.

💡Note: Check out my guide on how to Install Paperless-NGX With PostgreSQL as a Database.

💡Note: Check out my new guide on how to Install Paperless-NGX on Your UGREEN NAS.

  • STEP 1

Please Support My work by Making a Donation.

  • STEP 2

Install Portainer using my step by step guide. If you already have Portainer installed on your Synology NAS, skip this STEP. Attention: Make sure you have installed the latest Portainer version.

  • STEP 3

Make sure you have a synology.me Wildcard Certificate. Follow my guide to get a Wildcard Certificate. If you already have a synology.me Wildcard certificate, skip this STEP.

  • STEP 4

Go to Control Panel / Login Portal / Advanced Tab / click Reverse Proxy. Follow the instructions in the image below.

Paperless-NGX on Your Synology NAS With MariaDB STEP 1

  • STEP 5

Now click the “Create” button. Follow the instructions in the image below.

Paperless-NGX on Your Synology NAS With MariaDB STEP 2

  • STEP 6

After you click the Create button, the window below will open. Follow the instructions in the image below.

On the General area, set the Reverse Proxy Name description: type in Paperless-NGX. After that, add the following instructions:

Source:
Protocol: HTTPS
Hostname: paperlessngx.yourname.synology.me
Port: 443

Check Enable HSTS

Destination:
Protocol: HTTP
Hostname: localhost
Port: 8777

Paperless-NGX on Your Synology NAS With MariaDB STEP 3

  • STEP 7

On the Reverse Proxy Rules click the Custom Header tab. Click Create and then, from the drop-down menu, click WebSocket. After you click on WebSocket, two Header Names and two Values will be automatically added. Click Save. Follow the instructions in the image below.

Synology Proxy WebSocket

  • STEP 8

Go to Control Panel / Network / Connectivity tab/ Check Enable HTTP/2 then click Apply. Follow the instructions in the image below.

Paperless-NGX on Your Synology NAS With MariaDB STEP 4

  • STEP 9

Go to Control Panel / Security / Advanced tab/ Check Enable HTTP Compression then click Apply. Follow the instructions in the image below.

Paperless-NGX on Your Synology NAS With MariaDB STEP 5

  • STEP 10

Go to File Station and open the docker folder. Inside the docker folder, create one new folder and name it paperlessngx. Follow the instructions in the image below.
Note: Be careful to enter only lowercase, not uppercase letters.

Paperless-NGX on Your Synology NAS With MariaDB STEP 6

  • STEP 11

Now create seven new folders inside the paperlessngx folder that you created at STEP 10 and name them consume, data, db, export, media, redis, trash. Follow the instructions in the image below.
Note: Be careful to enter only lowercase, not uppercase letters.

Paperless-NGX on Your Synology NAS With MariaDB STEP 7

  • STEP 12

Log into Portainer using your username and password. On the left sidebar in Portainer, click on Stacks then + Add stack. Follow the instructions in the image below.

1 Synology Portainer Add Stack

  • STEP 13

In the Name field type in paperlessngx. Follow the instructions in the image below.

Note: Copy Paste the code below in the Portainer Stacks Web editor.

services:
  redis:
    image: redis:7
    command:
      - /bin/sh
      - -c
      - redis-server --requirepass redispass
    container_name: PaperlessNGX-REDIS
    hostname: paper-redis
    mem_limit: 512m
    mem_reservation: 256m
    cpu_shares: 768
    security_opt:
      - no-new-privileges:true
    read_only: true
    user: 1026:100
    healthcheck:
      test: ["CMD-SHELL", "redis-cli ping || exit 1"]
    volumes:
      - /volume1/docker/paperlessngx/redis:/data:rw
    environment:
      TZ: Europe/Bucharest
    restart: on-failure:5
    
  db:
    image: mariadb:11.4-noble #LTS Long Time Support Until May 29, 2029.
    container_name: PaperlessNGX-DB
    security_opt:
      - no-new-privileges:false
    hostname: paper-db
    environment:
      MYSQL_DATABASE: paperless
      MYSQL_USER: paperlessuser
      MYSQL_PASSWORD: paperlesspass
      MYSQL_ROOT_PASSWORD: rootpass
      TZ: Europe/Bucharest
    volumes:
      - /volume1/docker/paperlessngx/db:/var/lib/mysql:rw
    restart: on-failure:5
    
  phpmyadmin:
    image: phpmyadmin
    hostname: paperlessngx-phpmyadmin
    healthcheck:
     test: curl -f http://localhost:80/ || exit 1
    container_name: PaperlessNGX-phpMyAdmin
    ports:
      - 2980:80
    environment:
     PMA_HOST: paper-db
     PMA_PORT: 3306
    restart: on-failure:5
    
  gotenberg:
    image: gotenberg/gotenberg:latest
    container_name: PaperlessNGX-GOTENBERG
    hostname: gotenberg
    security_opt:
      - no-new-privileges:true
    user: 1026:100
    command:
      - "gotenberg"
      - "--chromium-disable-javascript=true"
      - "--chromium-allow-list=file:///tmp/.*"
      - "--api-timeout=300s"
    restart: on-failure:5

  tika:
    image: ghcr.io/paperless-ngx/tika:latest
    container_name: PaperlessNGX-TIKA
    hostname: tika
    security_opt:
      - no-new-privileges:true
    user: 1026:100
    restart: on-failure:5

  paperless:
    image: ghcr.io/paperless-ngx/paperless-ngx:latest
    container_name: PaperlessNGX
    hostname: paperless-ngx
    mem_limit: 6g
    cpu_shares: 1024
    security_opt:
      - no-new-privileges:true
    healthcheck:
      test: ["CMD", "curl", "-fs", "-S", "--max-time", "2", "http://localhost:8000"]
      interval: 30s
      timeout: 10s
      retries: 5
    ports:
      - 8777:8000
    volumes:
      - /volume1/docker/paperlessngx/data:/usr/src/paperless/data:rw
      - /volume1/docker/paperlessngx/media:/usr/src/paperless/media:rw
      - /volume1/docker/paperlessngx/export:/usr/src/paperless/export:rw
      - /volume1/docker/paperlessngx/consume:/usr/src/paperless/consume:rw
      - /volume1/docker/paperlessngx/trash:/usr/src/paperless/trash:rw
    environment:
      PAPERLESS_REDIS: redis://:redispass@paper-redis:6379
      PAPERLESS_DBENGINE: mariadb
      PAPERLESS_DBHOST: paper-db
      PAPERLESS_DBNAME: paperless
      PAPERLESS_DBUSER: paperlessuser
      PAPERLESS_DBPASS: paperlesspass
      PAPERLESS_EMPTY_TRASH_DIR: ../trash
      PAPERLESS_FILENAME_FORMAT: '{{ created_year }}/{{ correspondent }}/{{ document_type }}/{{ title }}'
      PAPERLESS_OCR_ROTATE_PAGES_THRESHOLD: 6
      PAPERLESS_TASK_WORKERS: 1
      USERMAP_UID: 1026
      USERMAP_GID: 100
      PAPERLESS_TIME_ZONE: Europe/Bucharest
      PAPERLESS_ADMIN_USER: marius
      PAPERLESS_ADMIN_PASSWORD: mariushosting
      PAPERLESS_URL: https://paperlessngx.yourname.synology.me
      PAPERLESS_CSRF_TRUSTED_ORIGINS: https://paperlessngx.yourname.synology.me
      PAPERLESS_OCR_LANGUAGE: deu+eng
      PAPERLESS_TIKA_ENABLED: 1
      PAPERLESS_TIKA_GOTENBERG_ENDPOINT: http://gotenberg:3000
      PAPERLESS_TIKA_ENDPOINT: http://tika:9998
    restart: on-failure:5
    depends_on:
      db:
        condition: service_started
      redis:
        condition: service_healthy
      tika:
        condition: service_started
      gotenberg:
        condition: service_started

Note: Before you paste the code above in the Web editor area below, change the value numbers for user with your own UID and GID values. (Follow my step by step guide on how to do this.) 1026 is my personal UID value and 100 is my personal GID value. You have to type in your own values.
Note: Before you paste the code above in the Web editor area, change the value for TZ with your own time zone value. (Select your current Time Zone from this list.)
Note: Before you paste the code above in the Web editor area, change the values for USERMAP_UID and USERMAP_GID with your own number values. (Follow my step by step guide on how to do this.)
Note: Before you paste the code above in the Web editor area, change the value for PAPERLESS_TIME_ZONE with your own time zone value. (Select your current Time Zone from this list.)
Note: Before you paste the code above in the Web editor area, change the value for PAPERLESS_ADMIN_USER and add your own username. marius is an example of a username. You have to insert your own username.
Note: Before you paste the code above in the Web editor area, change the value for PAPERLESS_ADMIN_PASSWORD and add your own password. mariushosting is an example of a password. You have to insert your own password.
Note: Before you paste the code above in the Web editor area below, change the value for PAPERLESS_URL and type in your own synology.me DDNS with https:// at the beginning that you have previously created at STEP 6.
Note: Before you paste the code above in the Web editor area below, change the value for PAPERLESS_CSRF_TRUSTED_ORIGINS and type in your own synology.me DDNS with https:// at the beginning that you have previously created at STEP 6.
Note: Before you paste the code above in the Web editor area below, change the value for PAPERLESS_OCR_LANGUAGE and type in your own OCR language. deu+eng is for German and English. nld+eng is for Dutch and English. It’s important to understand that you need to add your own language firs AND then +eng for English. +eng is always mandatory. If you only add your OCR language, like deu, but not +eng, then paperless won’t work.

PaperlessNGX on Your Synology NAS With MariaDB STEP 8 new 2025

  • STEP 14

Scroll down on the page until you see a button named Deploy the stack. Click on it. Follow the instructions in the image below. The installation process can take up to a few minutes. It will depend on your Internet speed connection.

PaperlessNGX on Your Synology NAS With MariaDB STEP 9 new 2025

⌛Now just wait because the Paperless NGX image is about 3.5GB.

  • STEP 15

If everything goes right, you will see the following message at the top right of your screen: “Success Stack successfully deployed“.

Paperless-NGX on Your Synology NAS With MariaDB STEP 10

  • STEP 16

Go back to STEP 1 or you will deal with karma 🙂.

  • STEP 17

Please wait approximately 5 minutes or you will get a blank synology error page if you try to connect too soon. Now open your browser and type in your HTTPS/SSL certificate like this https://paperlessngx.yourname.synology.me that you have previously created at STEP 6. In my case it’s https://paperlessngx.mariushosting.synology.me If everything goes right, you will see the Paperless-NGX Login page. Type in your own admin Username and Password that you have previously created at STEP 13 then click Sign in. Follow the instructions in the image below. ⚠️Warning: if you get an error message that says Username and/or password incorrect, this means your NAS is slow and didn’t create the superadmin user. You need to wait 2-3 minutes longer and try to log in again. Don’t rush to change the password or reinstall everything from scratch, just wait.

Paperless-NGX on Your Synology NAS With MariaDB STEP 11

  • STEP 18

Start uploading your documents now with Office files support!

Paperless-NGX on Your Synology NAS With MariaDB STEP 12

Enjoy Paperless-ngx with Office files support!

Paperless-NGX on Your Synology NAS With MariaDB STEP 13

You can also enable Dark Mode and change the Sidebar Color Theme. On the left sidebar click on Settings then follow the instructions below.

Uncheck Use system settings
Check Enable dark mode.
Uncheck Invert thumbnails in dark mode.
Change your Theme Color then click Save. Follow the instructions in the image below.

Paperless-NGX on Your Synology NAS With MariaDB STEP 14

  • STEP 19

phpMyAdmin is the graphical interface for the MariaDB database. It will help you connect to your database. Open your browser and type in http://Synology-ip-address:2980 Connect to your MariaDB using root as Username and rootpass as Password. Click Log in. Follow the instructions in the image below.

Paperless-NGX on Your Synology NAS With MariaDB STEP 15

  • STEP 20

You can now download and back up your Paperless database. Warning: Do not expose the phpMyadmin instance to the Internet via Reverse Proxy. You can do it by using a strong password, but it’s not recommended to expose it. Keep it local.
Note: Find out how to backup your Paperless database using phpMyAdmin.
Note: Fix the error message: The phpMyAdmin configuration storage is not completely configured.

Paperless-NGX on Your Synology NAS With MariaDB STEP 16

🆘TROUBLESHOOTING

If you encounter issues by using this container, make sure to check out the Common Docker issues article.

🔥Troubleshoot: If you get the “Error while converting document to PDF: 503 Server Error: Service Unavailable for url: http://gotenberg:3000/forms/libreoffice/convert” – This is usually due to the server being “down” for scheduled maintenance or due to a heavy traffic load that prevents it from properly serving all incoming requests. You need to wait until the server is back up again. Also, the issue can be related to the fact that you are trying to access PaperlessNGX locally instead of via Reverse Proxy. Websocket at STEP 7 is mandatory.

🔥Troubleshoot: In case you get the following error message: Error occurred while consuming document invoice.pdf: DigitalSignatureError: Input PDF has a digital signature. OCR would alter the document, invalidating the signature, just add the following Environment variable in the compose at STEP 13:

PAPERLESS_OCR_USER_ARGS: '{"invalidate_digital_signatures": true}'

Add it after:

PAPERLESS_CSRF_TRUSTED_ORIGINS: https://paperlessngx.yourname.synology.me

It should look like this:

PAPERLESS_CSRF_TRUSTED_ORIGINS: https://paperlessngx.yourname.synology.me
PAPERLESS_OCR_USER_ARGS: '{"invalidate_digital_signatures": true}'

🔥Troubleshoot: If you want to add an OCR language that is not installed by default on Paperless-NGX, you just need to add the following Environment variables (BOTH) in the compose at STEP 13:



PAPERLESS_OCR_LANGUAGES: nld nor #Install the language packages, for example nld and nor for Dutch and Norway, or just nld for Dutch or nor for Norway or a combination of both.
PAPERLESS_OCR_LANGUAGE: eng #Set default language to English. This is mandatory. Without this environment variable, the other languages like nld or nor will not be installed.

💡Suggestion: You can also install Stirling-PDF to better manage your documents.
💡Suggestion: You can also install Documenso that provides secure and efficient digital document signing and processing.
💡Suggestion: You can also install DocuSeal that provides secure and efficient digital document signing and processing.

Note: Can I run Docker on my Synology NAS? See the supported models.
Note: How to Back Up Docker Containers on your Synology NAS.
Note: Find out how to update the Paperless-ngx container with the latest image.
NoteHow to Free Disk Space on Your NAS if You Run Docker.
NoteHow to Schedule Start & Stop For Docker Containers.
NoteHow to Activate Email Notifications.
NoteHow to Add Access Control Profile on Your NAS.
NoteHow to Change Docker Containers Restart Policy.
NoteHow to Use Docker Containers With VPN.
NoteConvert Docker Run Into Docker Compose.
Note: How to Clean Docker.
Note: How to Clean Docker Automatically.
Note: Best Practices When Using Docker and DDNS.
Note: Some Docker Containers Need WebSocket.
Note: Find out the Best NAS Models For Docker.
Note: Activate Gmail SMTP For Docker Containers.

This post was updated on Tuesday / November 12th, 2024 at 8:43 PM