A rambling list of notes to myself about hosting a Lemmy instance like this one

Basic Setup

Docker guide: https://lemmy.villa-straylight.social/post/1849#

However, I like the docker-compose.yml in the official docs better as a starting point. The docs pages aren’t automatically published when a PR is merged, so refer to the Github Repo for the latest version.

This docker-compose.yml is mostly intended for development work, so you will need to replace the following lines:

    build:
      context: ../
      dockerfile: docker/Dockerfile

with

    image: dessalines/lemmy:0.17.4

Likewise, update the lemmy-ui image to dessalines/lemmy-ui:0.17.4.

I use basically the nginx.conf added by Just-Insane to the docker install page here.

Reverse Proxy

Lemmy uses websockets (for now anyway, that’s changing soon) and websockets are kind of dumb. If you put this setup behind a reverse proxy, you need to make sure the reverse proxy properly handles web sockets. For nginx, this essentially means you need to copy the settings in the docker nginx.conf into your fronting reverse proxy.

Example:

    server {
        listen 443 ssl http2;
        listen [::]:443 ssl http2;
        server_name lemmy.villa-straylight.social;
        ssl_certificate /etc/letsencrypt/live/villa-straylight.social/fullchain.pem; # managed by Certbot
        ssl_certificate_key /etc/letsencrypt/live/villa-straylight.social/privkey.pem; # managed by Certbot
        include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
        ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

        # frontend general requests
        location / {
            proxy_pass "http://localhost:[docker nginx port]";

            rewrite ^(.+)/+$ $1 permanent;
            # Send actual client IP upstream
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header Host $host;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }

        # backend
        location ~ ^/(api|pictrs|feeds|nodeinfo|.well-known) {
            proxy_pass "http://localhost:[docker nginx port]";
            # proxy common stuff
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";

            # Send actual client IP upstream
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header Host $host;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }
    }

Custom Themes

In docker-compose.yml, add a new volume to lemmy-ui, with /app/extra_themes as the path in the image. (Thanks to @tmpod@lemmy.pt for pointing that out)

Example:

  lemmy-ui:
    image: dessalines/lemmy-ui:0.17.3
    volumes:
      - ./volumes/lemmy_themes:/app/extra_themes/

You can then drop .css files in there (e.g. a copy of one of the default themes) and they will appear as an option in the user’s settings. The name of the theme is the file-name of the .css file.