How to Install Tianji on Your Synology NAS

How to Install Tianji on Your Synology NAS

Tianji is an open-source project dedicated to providing robust and efficient solutions for data integration and management. One sentence to summarize: Tianji = Website Analytics + Uptime Monitor + Server Status. You can use Tianji on your Synology NAS as an alternative to Plausible, Umami, Medama, MatomoĀ and Uptime Kuma. In this step by step guide I will show you how to install TianjiĀ on yourĀ Synology NAS using Docker & Portainer.

šŸ’”Note: This guide works perfectly with the latest version of Tianji v.1.17.6

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

Tianji Synology NAS Set up 1 new 2025

  • STEP 5

Now click the ā€œCreateā€ button. Follow the instructions in the image below.

Tianji Synology NAS Set up 2 new 2025

  • 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 Tianji. After that, add the following instructions:

Source:
Protocol:Ā HTTPS
Hostname: tianji.yourname.synology.me
Port:Ā 443

Check Enable HSTS

Destination:
Protocol:Ā HTTP
Hostname:Ā localhost
Port:Ā 12345

Tianji Synology NAS Set up 3 new 2025

  • 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 / Check Enable HTTP/2 then click Apply. Follow the instructions in the image below.

Tianji Synology NAS Set up 4 new 2025

  • STEP 9

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

Tianji Synology NAS Set up 5 new 2025

  • STEP 10

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

Tianji Synology NAS Set up 6 new 2025

  • STEP 11

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 12

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

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

services:
  db:
    image: postgres:17
    container_name: Tianji-DB
    hostname: tianji-db
    mem_limit: 1g
    cpu_shares: 1024
    security_opt:
      - no-new-privileges:true
    healthcheck:
      test: ["CMD", "pg_isready", "-q", "-d", "tianji", "-U", "tianjiuser"]
      timeout: 45s
      interval: 10s
      retries: 10
    volumes:
      - /volume1/docker/tianjidb:/var/lib/postgresql/data:rw
    environment:
      POSTGRES_DB: tianji
      POSTGRES_USER: tianjiuser
      POSTGRES_PASSWORD: tianjipass
    restart: on-failure:5
    
  tianji:
    image: moonrailgun/tianji
    container_name: Tianji
    healthcheck:
      test: ["CMD-SHELL", "nc -z 127.0.0.1 12345 || exit 1"]
      interval: 10s
      timeout: 5s
      retries: 3
      start_period: 90s
    ports:
      - 12345:12345
    environment:
      DATABASE_URL: postgresql://tianjiuser:tianjipass@tianji-db:5432/tianji
      JWT_SECRET: dOxZYTTZgXKMHkqLBIQVImayQXAVWdzGBPuFJKggzcgvgPJPXpWzqzKaUOIOGGIr
      ALLOW_REGISTER: false
      ALLOW_OPENAPI: true
      OPENAI_API_KEY: Your-OpenAI-APIKEY #NOT mandatory to add.
    depends_on:
      - db
    restart: on-failure:5

Note: Before you paste the code above in the Web editor area below, change the value for JWT_SECRET. (Generate your own Random 64 length JWT_SECRET.)

Tianji Synology NAS Set up 7 new 2025

  • STEP 13

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.

Tianji Synology NAS Set up 8 new 2025

  • STEP 14

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

Tianji Synology NAS Set up 9 new 2025

  • STEP 15

šŸŸ¢Please Support My work by Making a Donation. Almost 99,9% of the people that install something using my guidesĀ forget to support my work, or justĀ ignoreĀ STEP 1. Iā€™ve been very honest about this aspect of my work since the beginning: I donā€™t run any ADS, I donā€™t require subscriptions, paid or otherwise, I donā€™t collect IPs, emails, and I donā€™t have any referral links from Amazon or other merchants. I also donā€™t have any POP-UPs or COOKIES. I have repeatedly been told over the years how much I have contributed to the community. Itā€™s something I love doing and have been honest about my passion since the beginning. But I also Need The Community to Support me Back to be able to continue doing this work.

  • STEP 16

Now open your browser and type in your HTTPS address like this https://tianji.yourname.synology.me/loginĀ In my case it’s https://tianji.mariushosting.synology.me/login If everything goes right, you will see the Tianji login page. Type in the default Username and Password, then click Login. Follow the instructions in the image below.

āš ļøWarning: the default Username is adminĀ and the default Password is admin

Tianji Synology NAS Set up 10 new 2025

  • STEP 17

Change the default password. On the left sidebar, at the bottom, click on the 3 vertical dots, then Profile. Click Change Password. Follow the instructions in the image below.

Tianji Synology NAS Set up 11 new 2025

  • STEP 18

In the Old Password area, type in admin, then write down your new password. Click Submit. Follow the instructions in the image below.

Tianji Synology NAS Set up 12 new 2025

  • STEP 19

After you click Submit at STEP 18, you will be prompted to log in using your new password. Follow the instructions in the image below.

Tianji Synology NAS Set up 13 new 2025

  • STEP 20

Analyze your first website. On the left sidebar, click Website then the + icon. In the apposite fields, type in the website name and the domain address, then click Create. Follow the instructions in the image below.

Tianji Synology NAS Set up 14 new 2025

  • STEP 21

Copy your Auto-Generated code. Follow the instructions in the image below.

Tianji Synology NAS Set up 15 new 2025

  • STEP 22

Paste your personal Tianji Tracking code script that you have automatically generated at STEP 21 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 Tianji Tracking code script 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 Tianji Dashboard later.

Tianji Synology NAS Set up 16 new2 2025

  • STEP 23

Go back to your Tianji synology.me DDNS URL and start looking at the stats! After the Tianji Tracking code script is added to your website, Tianji will start to collect Real-Time analytics of your website. My blog doesnā€™t have any TRACKING CODE on it. I just installed Tianji 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.

Tianji Synology NAS Set up 17 new 2025

  • STEP 24

Monitor your first website. On the left sidebar, click Monitor then the + Add icon. In the apposite fields, type in the website name and the domain address, then click Create. Follow the instructions in the image below.

Tianji Synology NAS Set up 18 new 2025

  • STEP 25

Be the first who knows that your website is down. Reliable monitoring warns you before any significant troubles and saves you money. Tianji monitors your website constantly. Monitoring uptime for HTTP(s) / TCP / Ping. Fancy, Reactive, Fast UI/UX. Notifications via Webhook, Telegram, Discord and email (SMTP).

Tianji Synology NAS Set up 19 new 2025

  • STEP 26

If you want to allow user registration in Tianji, just change the following line in the compose at STEP 12:

ALLOW_REGISTER: false

with the following one:

ALLOW_REGISTER: true

Click update the stack to update the settings. From this point on, any user who will try to register a new account at https://tianji.yourname.synology.me/register will be able to do it.

Enjoy Tianji!

šŸ†˜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 Tianji container with the latest image.
Note: How to Free Disk Space on Your NAS if You Run Docker.
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.

This post was updated on Friday / January 10th, 2025 at 4:51 AM