How to Install Lemmy on Your Synology NAS

How to Install Lemmy on Your Synology NAS

Lemmy is a selfhosted social link aggregation and discussion platform. It is completely free and open, and not controlled by any company. This means that there is no advertising, tracking, or secret algorithms. Content is organized into communities, so it is easy to subscribe to topics that you are interested in, and ignore others. Voting is used to bring the most interesting items to the top. There are strong moderation tools to keep out spam and trolls. A Lemmy website can operate alone. Just like a traditional website, people sign up on it, post messages, upload pictures and talk to each other. Unlike a traditional website, Lemmy instances can interoperate, letting their users communicate with each other. In this step by step guide I will show you how to install Lemmy on your Synology NAS using Docker & Portainer.

💡Note: This guide works perfectly with the latest Lemmy v0.19.7 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 / Network / Connectivity tab/ Check Enable HTTP/2 then click Apply. Follow the instructions in the image below.

Lemmy Synology NAS Set up 1

  • STEP 5

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

Lemmy Synology NAS Set up 2

  • STEP 6

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

Lemmy Synology NAS Set up 3

  • STEP 7

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

Lemmy Synology NAS Set up 4

  • STEP 8

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

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

Check Enable HSTS

Destination:
Protocol: HTTP
Hostname: localhost
Port: 8536

Lemmy Synology NAS Set up 5

  • STEP 9

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 10

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

Lemmy Synology NAS Set up 6

  • STEP 11

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

Lemmy Synology NAS Set up 7

  • STEP 12

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

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

Check Enable HSTS

Destination:
Protocol: HTTP
Hostname: localhost
Port: 1236

Lemmy Synology NAS Set up 8

  • STEP 13

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 14

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

Lemmy Synology NAS Set up 9

  • STEP 15

Now create two new folders inside the lemmy folder that you created at STEP 14 and name them db and pictrs. Follow the instructions in the image below.
Note: Be careful to enter only lowercase, not uppercase letters.

Lemmy Synology NAS Set up 10

  • STEP 16

Download (click on the blue link below) then upload the nginx.conf file below in the lemmy folder that you have previously created at STEP 14. Follow the instructions in the image below. 🔒Note: Support my work to unlock the password. You can use this password to download any file on mariushosting forever!

👉🏻nginx.conf

Lemmy Synology NAS Set up 11

  • STEP 17

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 18

Download the config.hjson file by clicking the blue link below. Using notepad or something similar on your computer, change the SMTP lines, LEMMY ADMIN lines and DDNS line. After you add your own parameters as per the example below, save the file. Follow the instructions in the image below. 🔒Note: Support my work to unlock the password. You can use this password to download any file on mariushosting forever!

👉🏻Download config.hjson

⚠️Warning: Do not change any of the other values. All the values should be inside ” “.
SMTP
smtp_login: “YourOwnGmailAddress” STEP 17.
smtp_passowrd: “YourOwnGmailAPPassword” STEP 17.
smtp_from_address: “YourOwnGmailAddress” STEP 17.

⚠️Warning: Do not change any of the other values. All the values should be inside ” “.
LEMMY ADMIN
admin_username: “yourowname”
admin_password: “yourownpassword”
site_name: “yourfavoritesitename”
admin_email: “yourownemail”

⚠️Warning
: Do not change any of the other values. All the values should be inside ” “.
Synology DDNS
hostname: “lemmy.yourname.synology.meSTEP 12.

Lemmy Synology NAS Set up 12

  • STEP 19

Now upload the config.hjson file with your own parameters in the lemmy folder that you have previously created at STEP 14. Follow the instructions in the image below.

Lemmy Synology NAS Set up 13

  • STEP 20

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 21

In the Name field type in lemmy. 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:16
    command:
      [
        "postgres",
        "-c",
        "session_preload_libraries=auto_explain",
        "-c",
        "auto_explain.log_min_duration=5ms",
        "-c",
        "auto_explain.log_analyze=true",
        "-c",
        "track_activity_query_size=1048576",
      ]
    container_name: Lemmy-DB
    hostname: lemmy-db
    mem_limit: 1g
    cpu_shares: 1024
    security_opt:
      - no-new-privileges:true
    healthcheck:
      test: ["CMD", "pg_isready", "-q", "-d", "lemmy", "-U", "lemmyuser"]
      timeout: 45s
      interval: 10s
      retries: 10
    volumes:
      - /volume1/docker/lemmy/db:/var/lib/postgresql/data:rw
    environment:
      POSTGRES_DB: lemmy
      POSTGRES_USER: lemmyuser
      POSTGRES_PASSWORD: lemmypass
    restart: on-failure:5

  pictrs:
    image: asonix/pictrs:0.5.0-rc.2
    container_name: Lemmy-PICTRS
    hostname: lemmy-pictrs
    mem_limit: 2g
    cpu_shares: 768
    security_opt:
      - no-new-privileges:true
    user: 1026:100
    healthcheck:
      test: stat /etc/passwd || exit 1
    volumes:
      - /volume1/docker/lemmy/pictrs:/mnt:rw
    environment:
      PICTRS_OPENTELEMETRY_URL: http://otel:4137
      RUST_LOG: debug
      RUST_BACKTRACE: full
      PICTRS__MEDIA__VIDEO_CODEC: vp9
      PICTRS__MEDIA__GIF__MAX_WIDTH: 256
      PICTRS__MEDIA__GIF__MAX_HEIGHT: 256
      PICTRS__MEDIA__GIF__MAX_AREA: 65536
      PICTRS__MEDIA__GIF__MAX_FRAME_COUNT: 400
    restart: on-failure:5

  lemmy-back:
    image: dessalines/lemmy:0.19.3
    container_name: Lemmy-BACK
    hostname: lemmy-back
    mem_limit: 2g
    cpu_shares: 768
    security_opt:
      - no-new-privileges:true
    user: 1026:100
    volumes:
      - /volume1/docker/lemmy/config.hjson:/config/config.hjson:ro
    environment:
      RUST_LOG: "warn,lemmy_server=debug,lemmy_api=debug,lemmy_api_common=debug,lemmy_api_crud=debug,lemmy_apub=debug,lemmy_db_schema=debug,lemmy_db_views=debug,lemmy_db_views_actor=debug,lemmy_db_views_moderator=debug,lemmy_routes=debug,lemmy_utils=debug,lemmy_websocket=debug"
      RUST_BACKTRACE: full
    restart: on-failure:5
    depends_on:
      pictrs:
        condition: service_healthy
      db:
        condition: service_healthy

  lemmy-front:
    image: dessalines/lemmy-ui:0.19.3
    container_name: Lemmy-FRONT
    hostname: lemmy-front
    mem_limit: 2g
    cpu_shares: 768
    security_opt:
      - no-new-privileges:true
    read_only: false
    user: 1026:100
    healthcheck:
      test: wget --no-verbose --tries=1 --spider http://localhost:1234
    environment:
      LEMMY_UI_LEMMY_INTERNAL_HOST: lemmy-back:8536
      LEMMY_UI_LEMMY_EXTERNAL_HOST: https://lemmy.yourname.synology.me
      LEMMY_HTTPS: true #true
    restart: on-failure:5
    depends_on:
      lemmy-back:
        condition: service_started

  proxy:
    image: nginx:1-alpine
    container_name: Lemmy-NGINX
    hostname: lemmy-nginx
    mem_limit: 1g
    cpu_shares: 1024
    security_opt:
      - no-new-privileges:true
    healthcheck:
      test: curl -f http://localhost:1236/ || exit 1
    ports:
      - 1236:1236
      - 8536:8536
    volumes:
      - /volume1/docker/lemmy/nginx.conf:/etc/nginx/nginx.conf:ro
    restart: on-failure:5
    depends_on:
      pictrs:
        condition: service_healthy
      lemmy-front:
        condition: service_healthy

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 LEMMY_UI_LEMMY_EXTERNAL_HOST and type in your own synology.me DDNS with https:// at the beginning that you have previously created at STEP 12.

Lemmy-Synology-NAS-Set-up-14-new-2024

  • STEP 22

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.

Lemmy-Synology-NAS-Set-up-15-new-2024

  • STEP 23

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

Lemmy Synology NAS Set up 16

  • STEP 24

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

  • STEP 25

Now open your browser and type in your HTTPS/SSL certificate like this https://lemmy.yourname.synology.me that you have previously created at STEP 12. In my case it’s https://lemmy.mariushosting.synology.me If everything goes right, you will see the Lemmy Login page. At the top right of the page click Login. Follow the instructions in the image below.

Lemmy Synology NAS Set up 17

  • STEP 26

Type in your own Email Address and Password that you have previously created in your own config.hjson file at STEP 18. Click Login. Follow the instructions in the image below.

Lemmy Synology NAS Set up 18

  • STEP 27

At the top right of the page click on your name then Settings. Change your settings like the email, avatar, banner, display name, languages and password. Scroll down the page a little bit. Follow the instructions in the image below.

Lemmy Synology NAS Set up 19

  • STEP 28

Choose your favorite Theme, then click Save to save the settings. Follow the instructions in the image below.

Lemmy Synology NAS Set up 20

  • STEP 29

Click Create Community to create your first community on your own Lemmy server.

Lemmy Synology NAS Set up 21

  • STEP 30

If someone wishes to sign up to your server, they must click the Sign Up button at the top right of the page, then add their details and click Sign Up. Follow the instructions in the image below.

Lemmy Synology NAS Set up 22

  • STEP 31

Once a new user registers to your server, you, as an administrator, will see a little notification at the top right of the page. Click on it. Follow the instructions in the image below.

Lemmy Synology NAS Set up 23

  • STEP 32

You need to manually Approve the new user by clicking the Approve button. Follow the instructions in the image below.

Lemmy Synology NAS Set up 24

  • STEP 33

Once a user is registered, they automatically receive a message via email that says their registration application has been approved, on the condition that you, as an administrator, have clicked the Approve button as per the instructions at STEP 32.

Lemmy Synology NAS Set up 25

Enjoy Lemmy!

🆘TROUBLESHOOTING

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

Full Lemmy Documentation

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 Lemmy 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.
Note: Activate Gmail SMTP For Docker Containers.

This post was updated on Wednesday / November 27th, 2024 at 10:29 AM