shadowsnow

shadowsnow

一个难民,一个被不允许使用电子产品的难民

How to install Mastodon on Synology NAS

Mastodon is a free and open-source social network server based on ActivityPub, where users can follow friends and discover new ones. On Mastodon, users can post anything they want: links, images, text, videos. All Mastodon servers can interoperate as a federated network (users on one server can seamlessly communicate with users on another server, including non-Mastodon software that implements ActivityPub, such as 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.1.2 version.
Use my step-by-step guide to install Portainer. If you have already installed Portainer on your Synology NAS, please skip this step. Note: Make sure you have the latest version of Portainer installed.

Step 3
Make sure you have a synology.me wildcard certificate. Follow my guide to obtain a wildcard certificate. If you already have a synology.me Wildcard certificate, please skip this step.

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

Step 5
Now click the "Create" button. Follow the instructions in the image below.

Mastodon Synology NAS Setup 2

Step 6
After clicking the "Create" button, the window below will open. Follow the instructions in the image below.

In the General area, set the reverse proxy name description: enter Mastodon. Then, add the following details:

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

Check Enable HSTS

Destination:
Protocol: HTTPS
Hostname: localhost
Port: 8562

Mastodon Synology NAS Setup 3 new

Step 7
Click on the Custom Headers tab in the Reverse Proxy Rules. Click Create, then click WebSocket from the dropdown menu. After clicking 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 and then click Apply. Follow the instructions in the image below.

Mastodon Synology NAS Setup 4

Step 9
Go to Control Panel / Security / Advanced tab / check Enable HTTP Compression, and then click Apply. Follow the instructions in the image below.

Mastodon Synology NAS Setup 5

Step 10
Go to File Station and open the docker folder. In the docker folder, create a new folder and name it mastodon. Follow the instructions in the image below.
Note: Make sure to only enter lowercase letters, do not use uppercase letters.

Mastodon Synology NAS Setup 6

Step 11
Now create three new folders in the mastodon folder you created in Step 10 and name them config, db, redis. Follow the instructions in the image below. Note: Make sure to only enter lowercase letters, do not use uppercase letters.

Mastodon Synology NAS Setup 7

Step 12
Log in to Portainer using your username and password. In the left sidebar of Portainer, click Stacks, then click + Add stack. Follow the instructions in the image below.

1 Synology Portainer Add Stack

Step 13
Enter mastodon in the name field. Follow the instructions in the image below.

Note: Copy and paste the following code into the Portainer Stacks Web editor.
version: "3.9"
services:
mastodon-redis:
image: redis
container_name: Mastodon-REDIS
hostname: mastodon-redis
security_opt:
- no-new-privileges
healthcheck:
test: ["CMD-SHELL", "redis-cli ping || exit 1"]
user: 1026:100
environment:
- TZ=Europe/Bucharest
volumes:
- /volume1/docker/mastodon/redis:/data
restart: always

mastodon-db:
image: postgres
container_name: Mastodon-DB
hostname: mastodon-db
security_opt:
- no-new-privileges
healthcheck:
test: ["CMD", "pg_isready", "-q", "-d", "mastodon", "-U", "mastodonuser"]
timeout: 45s
interval: 10s
retries: 10
user: 1026:100
volumes:
- /volume1/docker/mastodon/db:/var/lib/postgresql/data
environment:
POSTGRES_DB: mastodon
POSTGRES_USER: mastodonuser
POSTGRES_PASSWORD: mastodonpw
restart: always

mastodon:
image: lscr.io/linuxserver/mastodon
container_name: Mastodon
hostname: mastodon
security_opt:
- no-new-privileges
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=2e80b1b7d3a70f6358ab08a1cebdffc2424d8800c8ff764ff238f892abd539ff70000f31310d21ac7391d281795479b6d97263edd5d88c05070b6b8acbadf2ab
- OTP_SECRET=eca299ae599a9b4eda009b2abfc1ee5b01e0ca30eea060f2a47c6ca3075c4d3616df992ae7e437fcd061aeb6dc9f9cc3d38e79ab090324092777984478996c06
- S3_ENABLED=false
volumes:
- /volume1/docker/mastodon/config:/config
ports:
- 8562:443
restart: always
depends_on:
mastodon-redis:
condition: service_healthy
mastodon-db:
condition: service_started
Note: Before pasting the above code into the Web editor area below, change the user value numbers to your own UID and GID values (following my step-by-step guide on how to do this). 1026 is my personal UID value, and 100 is my personal GID value. You must enter your own values.
Note: Before pasting the above code into the Web editor area below, change the value of TZ. (Select your current timezone from this list.)
Note: Before pasting the above code into the Web editor area below, change the values of PUID and PGID to 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 must enter your own values.
Note: Before pasting the above code into the Web editor area below, change the value of LOCAL_DOMAIN and enter your own synology.me DDNS created in Step 6.
Note: Before pasting the above code into the Web editor area below, change the value of WEB_DOMAIN and enter your own synology.me DDNS created in Step 6.

Mastodon Synology NAS Setup 8

Step 14
Scroll down the page until you see the button named Deploy the stack. Click it. Follow the instructions in the image below. The installation process may take a few minutes, depending on your internet connection speed.

Mastodon Synology NAS Setup 9 new 2023

Step 15
If everything goes well, you will see the following message in the upper right corner of the screen: “Success Stack successfully deployed.”

Mastodon Synology NAS Setup 10

Step 16
In the left sidebar of Portainer, click Containers. Identify your Mastodon instance and click the small terminal icon. Follow the instructions in the image below.

Mastodon Synology NAS Setup 11

Step 17
After clicking the small terminal icon in Step 16, a new page will open. Click "Connect." Follow the instructions in the image below.

Mastodon Synology NAS Setup 12

Step 18
After clicking Connect at STEP 17, a console will open. Copy and paste the code below and follow the instructions in the image.

tootctl accounts create marius --email yourownemail --confirmed --role owner
Click to copy🐋
Note: Before pasting the above code into the console area below, change marius to your own name.
Note: Before pasting the above code into the console area below, change yourownemail to your own email text.

Mastodon Synology NAS Setup 13 new

Step 19
After inserting the code, press the Enter key on your keyboard to confirm and start the process of creating a password. After a few seconds, you will receive a new password for the user you created in Step 18. Copy the password and keep it in a safe place - you will need it later.

Mastodon Synology NAS Setup 14

Step 20
Go back to Step 1, or you will deal with karma 🙂.

Step 21
Now open your browser and enter your HTTPS/SSL certificate, for example, https://mastodon.yourname.synology.me. In my case, it is https://mastodon.mariushosting.synology.me. If everything goes well, you will see the Mastodon homepage. Click Login. Follow the instructions in the image below.

Mastodon Synology NAS Setup 15

Step 22
In the email address field, enter the email you selected in Step 18. In the password field, enter the password you automatically generated in Step 19. Click "Login." Follow the instructions in the image below.

Mastodon Synology NAS Setup 16 new 2023

Step 23
Personalize your profile, then click Preferences to access your admin area. Follow the instructions in the image below.

Mastodon Synology NAS Setup 17

Step 24
In the left sidebar, click Administration. Follow the instructions in the image below.

Mastodon Synology NAS Setup 18

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

Mastodon Synology NAS Setup 19

Step 26
If new users subscribe to your server, you will find them under "Accounts" in the "Review" section. Click Accounts. Click the new user profile. Follow the instructions in the image below.

Mastodon Synology NAS Setup 20

Step 27
Click Confirm to approve 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, i.e., approve new members.
Note: To clarify: every user who registers a new account on your server needs to be manually confirmed before they can start using their profile on your Mastodon server. New users will not receive an email when they first register. I decided not to include an SMTP email server (in the docker compose) to automatically confirm new users to avoid overloading the email server. For this reason, I think it is fair that all new users are manually approved by the owner, administrator, or moderator, so you have complete control over who accesses your private Mastodon server. If you want new users to receive an automatic registration confirmation email, please consult with me.

Mastodon Synology NAS Setup 21

Enjoy your Mastodon server!

Note: Learn how to update the Mastodon container using the latest image.
Note: Can I run Docker on my Synology NAS? Check supported models.
Note: How to free up disk space on NAS when running Docker.
Note: How to schedule start and stop for Docker containers.
Note: How to enable email notifications.
Note: How to add access control profiles on your NAS.
Note: How to change Docker container restart policies.
Note: How to use Docker containers via VPN.
Note: How to convert Docker Run to Docker Compose.
Note: How to clean up Docker.
Note: How to automate Docker cleanup.
Note: Best practices when using Docker and DDNS.
Note: Some Docker containers require WebSocket.
Note: Find out the best NAS models for Docker.
Note: Activate Gmail SMTP for Docker containers.

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.