How to Install Mastodon on Your Synology NAS

How to Install Mastodon on Your Synology NAS

Mastodon is a free, open-source social network server based on ActivityPub where users can follow friends and discover new ones. On Mastodon, users can publish anything they want: links, pictures, text, video. All Mastodon servers are interoperable as a federated network (users on one server can seamlessly communicate with users from another one, including non-Mastodon software that implements ActivityPub like Pixelfed and WriteFreely). In this step by step guide I will show you how to install Mastodon on your Synology NAS using Docker and Portainer.

💡Note: This guide works perfectly with the latest Mastodon v4.3.1 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.

Mastodon Synology NAS Set up 1

  • STEP 5

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

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

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

Check Enable HSTS

Destination:
Protocol: HTTPS
Hostname: localhost
Port: 8562

Mastodon Synology NAS Set up 3 new

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

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

Mastodon 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 mastodon. Follow the instructions in the image below.
Note: Be careful to enter only lowercase, not uppercase letters.

Mastodon Synology NAS Set up 6

  • STEP 11

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

Mastodon Synology NAS Set up 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 mastodon. Follow the instructions in the image below.

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

services:
  mastodon-redis:
    image: redis
    container_name: Mastodon-REDIS
    hostname: mastodon-redis
    security_opt:
      - no-new-privileges:true
    healthcheck:
      test: ["CMD-SHELL", "redis-cli ping || exit 1"]
    user: 1026:100
    environment:
      - TZ=Europe/Bucharest
    volumes:
      - /volume1/docker/mastodon/redis:/data:rw
    restart: on-failure:5

  mastodon-db:
    image: postgres:17
    container_name: Mastodon-DB
    hostname: mastodon-db
    security_opt:
      - no-new-privileges:true
    healthcheck:
      test: ["CMD", "pg_isready", "-q", "-d", "mastodon", "-U", "mastodonuser"]
      timeout: 45s
      interval: 10s
      retries: 10
    volumes:
      - /volume1/docker/mastodon/db:/var/lib/postgresql/data:rw
    environment:
      POSTGRES_DB: mastodon
      POSTGRES_USER: mastodonuser
      POSTGRES_PASSWORD: mastodonpw
    restart: on-failure:5
    
  mastodon:
    image: lscr.io/linuxserver/mastodon:latest
    container_name: Mastodon
    hostname: mastodon
    security_opt:
      - no-new-privileges:true
    environment:
      - PUID=1026
      - PGID=100
      - TZ=Europe/Bucharest
      - DEFAULT_LOCALE=en
      - LOCAL_DOMAIN=mastodon.yourname.synology.me
      - WEB_DOMAIN=mastodon.yourname.synology.me
      - REDIS_HOST=mastodon-redis
      - REDIS_PORT=6379
      - DB_HOST=mastodon-db
      - DB_USER=mastodonuser
      - DB_NAME=mastodon
      - DB_PASS=mastodonpw
      - DB_PORT=5432
      - ES_ENABLED=false
      - ES_HOST=es
      - ES_PORT=9200
      - ES_USER=elastic
      - ES_PASS=elastic
      - SECRET_KEY_BASE=PIWLVVi14fqae5Ds8JqEGb3jGv3zVWJOoyxo6B2346vA00S3lzSL0cf3J0yxcB5pmu05qUHLQwIG8m8M97w56qvflufm7qdlRWoZoQ7sQjMDypdhRC54FcGD3rlSsBk4
      - OTP_SECRET=wjZtoiw3udx1V586bVkGCkg1MrZ0UuRBSKVj8ghsrF4eGSCPLMhHw234lGRwkTAMUKy5TRZbUXgPqK5POkvCVof8lse7KJGVPgWHdkwrvyzhUTPp8b1vvBMABVQ76rCM
      - ACTIVE_RECORD_ENCRYPTION_PRIMARY_KEY=6egLIdkH0vE5UXIwyZeU1qSL6tXwhd4j
      - ACTIVE_RECORD_ENCRYPTION_DETERMINISTIC_KEY=bMQ59AJmJRCogwsgeFuqt8BXqwAf1Yt8
      - ACTIVE_RECORD_ENCRYPTION_KEY_DERIVATION_SALT=ZpawFWM4ArOqRZbRtkYXeIqIKWLlsYZX
      - S3_ENABLED=false
    volumes:
      - /volume1/docker/mastodon/config:/config:rw
    ports:
      - 8562:443
    restart: on-failure:5
    depends_on:
      mastodon-redis:
        condition: service_healthy
      mastodon-db:
        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 below, change the value for TZ. (Select your current Time Zone from this list.)
Note: Before you paste the code above in the Web editor area below, change the value numbers for PUID and PGID with your own values. (Follow my step by step guide on how to do this.) 1026 is my personal PUID value and 100 is my personal PGID 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 LOCAL_DOMAIN and type in your own synology.me DDNS 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 WEB_DOMAIN and type in your own synology.me DDNS 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 SECRET_KEY_BASE. (Generate your own 128 length SECRET_KEY_BASE.)
Note: Before you paste the code above in the Web editor area below, change the value for OTP_SECRET. (Generate your own 128 length OTP_SECRET.)
Note: Before you paste the code above in the Web editor area below, change the value for ACTIVE_RECORD_ENCRYPTION_PRIMARY_KEY. (Generate your own 32 length ACTIVE_RECORD_ENCRYPTION_PRIMARY_KEY.)
Note: Before you paste the code above in the Web editor area below, change the value for ACTIVE_RECORD_ENCRYPTION_DETERMINISTIC_KEY. (Generate your own 32 length ACTIVE_RECORD_ENCRYPTION_DETERMINISTIC_KEY.)
Note: Before you paste the code above in the Web editor area below, change the value for ACTIVE_RECORD_ENCRYPTION_KEY_DERIVATION_SALT. (Generate your own 32 length ACTIVE_RECORD_ENCRYPTION_KEY_DERIVATION_SALT.)

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

Mastodon Synology NAS Set up 9 new 2026

  • STEP 15

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

Mastodon Synology NAS Set up 10

  • STEP 16

On the left sidebar in Portainer, click Containers. Identify your Mastodon instance, then click on the little terminal icon. Follow the instructions in the image below.

Mastodon Synology NAS Set up 11 new 2025

  • STEP 17

After you click on the little terminal icon at STEP 16, a new page will open. Click Connect. Follow the instructions in the image below.

Mastodon Synology NAS Set up 12

  • STEP 18

After you click Connect at STEP 17, a Console will open. Copy Paste the code below and follow the instructions in the image.

tootctl accounts create marius --email yourownemail --confirmed --role Owner

Note: Before you paste the code above in the Console area below, change marius with your own name.
Note: Before you paste the code above in the Console area below, change yourownemail text with your email.

Mastodon Synology NAS Set up 13 new

  • STEP 19

Once the code is inserted, confirm by pressing Enter on your keyboard to start the process of password creation. After some seconds, you will get a new password for the user you have previously created at STEP 18. Copy the password and save it in a safe place – you will need it later.

Mastodon Synology NAS Set up 14 new 2025

  • STEP 20

After your new password is created, copy paste the code below and follow the instructions in the image.

tootctl accounts approve marius

Note: Before you paste the code above in the Console area below, change marius with your own name that should be the same as the name that you have previously created at STEP 18.

Mastodon Synology NAS Set up 15A new 2025

  • STEP 21

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

  • STEP 22

Now open your browser and type in your HTTPS/SSL certificate like this https://mastodon.yourname.synology.me that you have previously created at STEP 6. In my case it’s https://mastodon.mariushosting.synology.me If everything goes right, you will see the main Mastodon page. Click Login. Follow the instructions in the image below.

Mastodon Synology NAS Set up 15B new 2025

  • STEP 23

On the E-mail address field type in the email you have chosen at STEP 18. On the Password field type in the password you have previously generated automatically at STEP 19. Click LOG IN. Follow the instructions in the image below.

Mastodon Synology NAS Set up 16 new 2025

  • STEP 24

Personalize your own profile, then click Preferences to access your Administration area. Follow the instructions in the image below.

Mastodon Synology NAS Set up 17

  • STEP 25

On the left sidebar click Administration. Follow the instructions in the image below.

Mastodon Synology NAS Set up 18

  • STEP 26

Under Administration, click Server Settings to personalize your Mastodon Server. Follow the instructions in the image below.

Mastodon Synology NAS Set up 19

  • STEP 27

If a new user will subscribe to your Server, you will find it under Moderation in the Accounts area. Click Accounts. Click on the new user profile. Follow the instructions in the image below.

Mastodon Synology NAS Set up 20

  • STEP 28

Click Confirm to confirm the new user. Once the new user is approved, they can start using your Mastodon server. Follow the instructions in the image below.
Note: Owners, Administrators and Moderators can confirm, that is approve, new members.
Note: Just to clarify: every user that will register a new account on your server will need manual confirmation to start using their profile on your Mastodon server. No Email will be sent to the new user when they register for the first time. I decided not to include the SMTP email server (in the docker compose) for automatic confirmation of new users so as not to overload the email server. For this reason, I thought it is only fair that all new users be manually approved by the owner, administrators or moderators so that you have complete control of the users coming to your private Mastodon server. If you want the new users to receive an automatic registration confirmation email, set up a consultation with me.

Mastodon Synology NAS Set up 21

Enjoy your Mastodon Server!

🆘TROUBLESHOOTING

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

Note: Find out how to update the Mastodon container with the latest image.
Note: How to Back Up Docker Containers on your Synology NAS.
Note: Can I run Docker on my Synology NAS? See the supported models.
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.
Note: Activate Gmail SMTP For Docker Containers.

This post was updated on Wednesday / October 23rd, 2024 at 2:42 PM