I understand this isn’t supported.

I’ve been trying to confangle this myself but not having much luck, feels like I’m missing some critical info on how to configure docker-compose.yml and nginx.conf. I’ve tried a few iterations now but here’s what I thought would be close. These are the only two files I’ve edited thus far, I’m using 0.16.2 for my 2nd front end so I can tell when I’m using it. I can view localhost:1236 fine but not localhost:1237 which gives me 502 bad gateway error, favicon still appears in tab though.

I’m thinking I need to open a separate port on lemmy to config another upstream entry in my nginx.conf? In prod the goal would be to have each frontend under a different subdomain for a research project I have in mind.

docker-compose.yml

version: '3.3'

services:
  nginx:
    image: nginx:1-alpine
    ports:
      - "1236:1236"
      - "1237:1237"
    volumes:
      - ./nginx.conf:/etc/nginx/nginx.conf
    restart: always
    depends_on:
      - pictrs
      - lemmy-ui
      - lemmy-uir

  lemmy:
    image: lemmy-dev:latest
    ports:
      - "8536:8536"
      - "6669:6669"
    restart: always
    environment:
      - RUST_LOG="warn,lemmy_server=debug,lemmy_api=debug,lemmy_api_common=debug,lemmy_api_crud=debug,lemmy_apub=debug,lemmy_db_schema=de>
    volumes:
      - ../lemmy.hjson:/config/config.hjson
    depends_on:
      - pictrs
      - postgres
      - otel

  lemmy-ui:
    image: dessalines/lemmy-ui:0.16.3
    restart: always
    environment:
      - LEMMY_INTERNAL_HOST=lemmy:8536
      - LEMMY_EXTERNAL_HOST=localhost:1234
      - LEMMY_HTTPS=false
      - LEMMY_UI_DEBUG=true
    depends_on:
      - lemmy

  lemmy-uir:
    image: dessalines/lemmy-ui:0.16.2
    restart: always
    environment:
      - LEMMY_INTERNAL_HOST=lemmy:8536
      - LEMMY_EXTERNAL_HOST=localhost:1235
      - LEMMY_HTTPS=false
      - LEMMY_UI_DEBUG=true
    depends_on:
      - lemmy

nginx.conf

worker_processes  1;
events {
    worker_connections  1024;
}
http {
    upstream lemmy {
        server "lemmy:8536";
    }
    upstream lemmy-ui {
        server "lemmy-ui:1234";
    }
    server {
      listen       1236;
      server_name  localhost 127.0.0.1;

      # frontend
      location / {
        set $proxpass "http://lemmy-ui";
        if ($http_accept = "application/activity+json") {
          set $proxpass "http://lemmy";
        }
        if ($http_accept = "application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\"") {
          set $proxpass "http://lemmy";
        }
        if ($request_method = POST) {
          set $proxpass "http://lemmy";
        }
        proxy_pass $proxpass;

        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://lemmy";
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";

        # Add IP forwarding headers
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      }
    }

    upstream lemmy-uir {
        server "lemmy-uir:1235";
    }
    server {
      listen       1237;
      server_name  localhost 127.0.0.1;

      # frontend
      location / {
        set $proxpass "http://lemmy-uir";
        if ($http_accept = "application/activity+json") {
          set $proxpass "http://lemmy";
        }
        if ($http_accept = "application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\"") {
          set $proxpass "http://lemmy";
        }
        if ($request_method = POST) {
          set $proxpass "http://lemmy";
        }
        proxy_pass $proxpass;

        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://lemmy";
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";

        # Add IP forwarding headers
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      }
    }
 }

logs for lemmy-uir, identical logs to lemmy-ui

docker-compose logs --tail=100 lemmy-uir
Attaching to dev_lemmy-uir_1
lemmy-uir_1  | Inferno is in development mode.
lemmy-uir_1  | httpbase: http://lemmy:8536
lemmy-uir_1  | wsUri: ws://lemmy:8536/api/v3/ws
lemmy-uir_1  | isHttps: false
lemmy-uir_1  | No JWT cookie found.
lemmy-uir_1  | http://0.0.0.0:1234

Grabbed this from the nginx logs:

nginx_1      | 2022/05/20 10:44:34 [error] 33#33: *10 connect() failed (111: Connection refused) while connecting to upstream, client: 192.168.137.1, server: localhost, request: "GET / HTTP/1.1", upstream: "http://172.25.0.8:1235/", host: "192.168.137.132:1237"
nginx_1      | 192.168.137.1 - - [20/May/2022:10:44:34 +0000] "GET / HTTP/1.1" 502 559 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.67 Safari/537.36"
nginx_1      | 2022/05/20 10:44:34 [error] 33#33: *10 connect() failed (111: Connection refused) while connecting to upstream, client: 192.168.137.1, server: localhost, request: "GET /favicon.ico HTTP/1.1", upstream: "http://172.25.0.8:1235/favicon.ico", host: "192.168.137.132:1237", referrer: "http://192.168.137.132:1237/

Support / questions about Lemmy.

  • 0 users online
  • 12 users / day
  • 24 users / week
  • 26 users / month
  • 19 users / 6 months
  • 11 subscribers
  • 140 Posts
  • 444 Comments
  • Modlog