How to Install Plausible on Your Synology NAS

How to Install Plausible on Your Synology NAS

Plausible Analytics is a simple, lightweight, open source and privacy-friendly alternative to Google Analytics, similar to Umami and Matomo. It doesn’t use cookies and is fully compliant with GDPR, CCPA and PECR. The mission of Plausible is to reduce corporate surveillance by providing an alternative web analytics tool which doesn’t come from the AdTech world. In this step by step guide I will show you how to install Plausible on your Synology NAS using Docker.

💡Note: This guide works perfectly with the latest Plausible v2.0.0 release.

  • 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.

Plausible Synology NAS Set up 1

  • STEP 5

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

Plausible Synology NAS Set up 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 Plausible. After that, add the following instructions:

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

Check Enable HSTS

Destination:
Protocol: HTTP
Hostname: localhost
Port: 9850

Plausible Synology NAS Set up 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.

Plausible Synology NAS Set up 4

  • STEP 9

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

Plausible Synology NAS Set up 5

  • STEP 10

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

Plausible Synology NAS Set up 6

  • STEP 11

Now create three new folders inside the plausible folder that you created at STEP 10 and name them data, db, logs. Follow the instructions in the image below.
Note: Be careful to enter only lowercase, not uppercase letters.

Plausible Synology NAS Set up 7

  • STEP 12

Follow my step by step guide on how to activate SMTP for your Gmail account. This step is mandatory. Note: If you don’t want to use the easiest way for SMTP with Google and you already have SMTP details from your own Mail Server, you can just skip this STEP and use your personalized email SMTP details instead.

  • STEP 13

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 14

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

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

version: "3.9"
services:
  db:
    image: postgres:15-alpine
    container_name: Plausible-DB
    hostname: plausible_db
    security_opt:
      - no-new-privileges:true
    volumes:
      - /volume1/docker/plausible/db:/var/lib/postgresql/data:rw
    environment:
      - POSTGRES_DB=plausible_db
      - POSTGRES_PASSWORD=postgres
    restart: on-failure:5

  events-db:
    image: clickhouse/clickhouse-server:23.6-alpine
    ulimits:
      nofile:
        soft: 262144
        hard: 262144
    container_name: Plausible-EVENTS-DB
    hostname: plausible_events_db
    security_opt:
      - no-new-privileges:true
    user: 1026:100
    volumes:
      - /volume1/docker/plausible/data:/var/lib/clickhouse:rw
      - /volume1/docker/plausible/logs:/var/log/clickhouse-server:rw
    restart: on-failure:5
      
  plausible:
    image: plausible/analytics:latest
    command: sh -c "sleep 10 && /entrypoint.sh db createdb && /entrypoint.sh db migrate && /entrypoint.sh db init-admin && /entrypoint.sh run"
    container_name: Plausible
    hostname: plausible
    security_opt:
      - no-new-privileges:true
    healthcheck:
      test: wget --no-verbose --tries=1 --spider http://localhost:8000/ || exit 1
    ports:
      - 9850:8000
    environment:
      DISABLE_REGISTRATION: false # Type in true Instead of false to Disable Registration After Your Initial Registration.
      BASE_URL: https://plausible.yourname.synology.me
      SECRET_KEY_BASE: fE2Z9z9idAfGOHzl3fAz1x4/zneBI3oel9R38k8icc6Ttlm0ZtLp3MS5Gd6RNhPzKEFpe3DeeL6x2rMm/+WZLQ==
    # MAILER_EMAIL: site@example.com
      SMTP_HOST_ADDR: smtp.gmail.com
      SMTP_HOST_PORT: 587
      SMTP_USER_NAME: Your-own-gmail-address
      SMTP_USER_PWD: Your-own-app-password
    restart: on-failure:5
    depends_on:
      - db
      - events-db

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 below, change the value for BASE_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 SMTP_USER_NAME and type in your own Gmail address. STEP 12.
Note: Before you paste the code above in the Web editor area below, change the value for SMTP_USER_PWD and type in your own Gmail app password. STEP 12.
Note: If you want, you can also add your own SMTP email details (not GMAIL) by removing the # in front of MAILER_EMAIL then adding your domain name email. If you don’t have your own SMTP details, and decide to use GMAIL SMTP from Google, then leave the code as it is with the #.

Plausible Synology NAS Set up 8 2024

  • STEP 15

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.

Plausible Synology NAS Set up 9 2024

  • STEP 16

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

Plausible Synology NAS Set up 10 2024

  • STEP 17

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

  • STEP 18

Now open your browser and type in your HTTPS/SSL certificate like this https://plausible.yourname.synology.me In my case it’s https://plausible.mariushosting.synology.me If everything goes right, you will see the Plausible main page. Type in your full name, your own email address and your own password. Confirm the password then click Create my account. Follow the instructions in the image below.

Plausible Synology NAS Set up 11

  • STEP 19

In the domain field type in your own domain name that you want to monitor. Select your Timezone then click Add snippet. Follow the instructions in the image below.

Plausible Synology NAS Set up 12

  • STEP 20

Copy your own JavaScript snippet then click Start collecting data. Follow the instructions in the image below.

Plausible Synology NAS Set up 13

  • STEP 21

Paste your personal JavaScript snippet that you have automatically generated at STEP 20 on your website between the <​head> and </head> tags of your site, then update your file. For example, I have a WordPress website hosted on a Synology NAS. If you have a WordPress website hosted elsewhere, know that the process is the same. Log into your WordPress admin Dashboard, click on the left sidebar on “Theme File Editor“, under Appearance. Select your theme then search for the header.php file. Paste your personal JavaScript snippet in the header.php file between the <​head> and </head> tags of your site, then update your file. Follow the instructions in the image below.
Note: You can add multiple websites via the Plausible Dashboard later.

Plausible Synology NAS Set up 14

Go back to your plausible synology.me DDNS and start looking at the stats! After the JavaScript snippet is added to your website, Plausible will start to collect Real-Time analytics of your website. My blog doesn’t have any TRACKING CODE on it. I just installed Plausible to show you how it works and how easily you can implement it on your website. I have already uninstalled it. Don’t forget to go back to STEP 1. I have worked hard for this guide so you can enjoy it.

Plausible Synology NAS Set up 15

  • STEP 22

One of the most important things you need to know about Plausible is that anyone can register for a new account by default. Follow my step by step guide below to disable registration of new users in Plausible. Go to Portainer then click Stacks. Click on plausible. Follow the instructions in the image below.

Plausible Synology NAS Set up 11 2024

  • STEP 23

Click on the Editor tab then scroll down the page a little bit. Follow the instructions in the image below.

Plausible Synology NAS Set up 12 2024

  • STEP 24

Change the value for DISABLE_REGISTRATION from false to true then scroll down the page until you find the Update the stack button. Click Update the stack. Follow the instructions in the image below.

Plausible Synology NAS Set up 13 2024

Enjoy Plausible!

🆘TROUBLESHOOTING

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

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 Plausible container with the latest image.
Note: How to Free Disk Space on Your NAS if You Run Docker.
Note: Instead of the synology.me DDNS you can also use your own domain name.
Note: How to Schedule Start & Stop For Docker Containers.
Note: How to Activate Email Notifications.
Note: How to Add Access Control Profile on Your NAS.
Note: How to Change Docker Containers Restart Policy.
Note: How to Use Docker Containers With VPN.
Note: Convert 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 Saturday / February 24th, 2024 at 8:13 PM