Hello, I’ve been trying to host my own lemmy instance for a little while now but have yet to be successful.

I recently had my lemmy instance running but i could not find other communities, so i decided to remove everything and try again. Now however when i try to create an account or log in i get the error 404 for the file /api/v3/user/loginand nothing happens.

I’ve tried removing everything again and starting again but it is still not working

in the lemmy docker container i get the following error

2023-07-06T12:27:55.845049Z  WARN lemmy_server::root_span_builder: couldnt_find_that_username_or_email: Record not found
   1: lemmy_server::root_span_builder::HTTP request
   0: lemmy_api::local_user::login::perform
             at crates/api/src/local_user/login.rs:16
           with http.method=POST http.scheme="http" http.host=lemmy.emphisia.nl http.target=/api/v3/user/login otel.kind="server" request_id=7896c156-ba9f-42cd-8f1a-c0233c3018a7
LemmyError { message: Some("couldnt_find_that_username_or_email"), inner: Record not found, context: SpanTrace [{ target: "lemmy_api::local_user::login", name: "perform", fields: "self=Login { username_or_email: Sensitive, password: Sensitive, totp_2fa_token: None }", file: "crates/api/src/local_user/login.rs", line: 16 }, { target: "lemmy_server::root_span_builder", name: "HTTP request", fields: "http.method=POST http.scheme=\"http\" http.host=lemmy.emphisia.nl http.target=/api/v3/user/login otel.kind=\"server\" request_id=7896c156-ba9f-42cd-8f1a-c0233c3018a7", file: "src/root_span_builder.rs", line: 16 }] }
           with self=Login { username_or_email: Sensitive, password: Sensitive, totp_2fa_token: None }
             at src/root_span_builder.rs:16

edit: i just managed to log in, however the federation does not seem to be working. None show up in the communities tab and if i look for any communities i get no results and this in the log

2023-07-06T14:09:32.699162Z  WARN lemmy_server::root_span_builder: couldnt_find_object: Failed to resolve actor via webfinger

   0: lemmy_apub::fetcher::search::search_query_to_object_id

             at crates/apub/src/fetcher/search.rs:19

   1: lemmy_apub::api::resolve_object::perform

           with self=ResolveObject { q: "!asklemmy", auth: Sensitive }

             at crates/apub/src/api/resolve_object.rs:21

   2: lemmy_server::root_span_builder::HTTP request

           with http.method=GET http.scheme="http" http.host=lemmy.emphisia.nl http.target=/api/v3/resolve_object otel.kind="server" request_id=34386e88-9099-4d83-a6a2-360ee7924064

             at src/root_span_builder.rs:16

LemmyError { message: Some("couldnt_find_object"), inner: Failed to resolve actor via webfinger, context: SpanTrace [{ target: "lemmy_apub::fetcher::search", name: "search_query_to_object_id", file: "crates/apub/src/fetcher/search.rs", line: 19 }, { target: "lemmy_apub::api::resolve_object", name: "perform", fields: "self=ResolveObject { q: \"!asklemmy\", auth: Sensitive }", file: "crates/apub/src/api/resolve_object.rs", line: 21 }, { target: "lemmy_server::root_span_builder", name: "HTTP request", fields: "http.method=GET http.scheme=\"http\" http.host=lemmy.emphisia.nl http.target=/api/v3/resolve_object otel.kind=\"server\" request_id=34386e88-9099-4d83-a6a2-360ee7924064", file: "src/root_span_builder.rs", line: 16 }] }

it doesn’t matter what i search, this always happens

  • Andreas
    link
    fedilink
    English
    arrow-up
    1
    ·
    1 year ago

    Yeah, the config file on the documentation sucks. I had to poke through several discussions on /c/selfhosting to find a config that wasn’t the extremely minimal one linked in the documentation. Your config.hjson is fine from what I can tell, although I’m not sure why you censored the hostname there as it’s supposed to be lemmy.emphisia.nl and not anything confidential.

    Honestly, I don’t have enough understanding of NGINX to debug its config, so I’ll just share my docker-compose.yml for leddit.danmark.party which worked correctly and federated out of the box, with a few adjustments to match your deployment. Note that you’ll have to tear down your existing deployment if you want to use this docker-compose.yml because they use the same ports.

    I should probably self-host my own pastebin
    version: "3.9"
    x-logging:
      &default-logging
      options:
        max-size: '10m'
      driver: json-file
    
    services:
      caddy:
        image: caddy:2
        volumes:
          - ./volumes/caddy:/data
          - ./volumes/caddy:/config
        # See Caddy's documentation for customizing this line
        # https://caddyserver.com/docs/quick-starts/reverse-proxy
        command:
          - /bin/sh
          - -c
          - |
            cat <<EOF > /etc/caddy/Caddyfile && caddy run --config /etc/caddy/Caddyfile
            
            {
              debug
            }
            
            (common) {
            	encode gzip
            	header {
            		-Server
            		Strict-Transport-Security "max-age=31536000; include-subdomains;"
            		X-XSS-Protection "1; mode=block"
            		X-Frame-Options "DENY"
            		X-Content-Type-Options nosniff
            		Referrer-Policy no-referrer-when-downgrade
            		X-Robots-Tag "none"
            	}
            }       
            
            # Lemmy instance
            lemmy.emphisia.nl {
              log
              import common
              reverse_proxy http://lemmy-ui:1234 # lemmy-ui
              
              @lemmy {
            		path /api/*
            		path /pictrs/*
            		path /feeds/*
            		path /nodeinfo/*
            		path /.well-known/*
            	}
             
             	@lemmy-hdr {
            		header Accept application/*
            	}
              
              handle @lemmy {
                reverse_proxy http://lemmy:8085 # lemmy
              }
              
              handle @lemmy-hdr {
                reverse_proxy http://lemmy:8085
              }
              
              @lemmy-post {
            		method POST
            	}
            
            	handle @lemmy-post {
            		reverse_proxy http://lemmy:8085
            	}
            }
            EOF
        lemmy:
          image: dessalines/lemmy:0.18.1-rc.9
          ports:
            - 8085:8536
          volumes:
            - ./lemmy.hjson:/config/config.hjson
          depends_on:
            - postgres
            - pictrs
          restart: always
          logging: *default-logging
          
        lemmy-ui:
          image: dessalines/lemmy-ui:0.18.1-rc.9
          ports:
           - 1234:1234
          environment:
            - LEMMY_UI_LEMMY_INTERNAL_HOST=lemmy:8085
            - LEMMY_UI_LEMMY_EXTERNAL_HOST=localhost:1236
          depends_on:
            - lemmy
          volumes:
            - ./volumes/lemmy-ui/extra_themes:/app/extra_themes
          restart: always
          logging: *default-logging
       
        postgres:
          image: postgres:15-alpine
          ports:
            - 5432:5432
          environment:
            - POSTGRES_USER=MyPostgresUser
            - POSTGRES_DB=MyPostgresDb
            - POSTGRES_PASSWORD=MyPostgresPassword
          volumes:
            - ./volumes/postgres:/var/lib/postgresql/data
          restart: always
          logging: *default-logging
          
        pictrs:
          image: asonix/pictrs:0.4.0-rc.7
          user: 991:991
          hostname: pictrs
          environment:
            - 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
          volumes:
            - ./volumes/pictrs:/mnt
          restart: always
          logging: *default-logging
    	  
        postfix:
          image: mwader/postfix-relay
          environment:
           - POSTFIX_myhostname=lemmy.emphisia.nl
          restart: "always"
          logging: *default-logging
    
    • youpie_temp@reddthat.comOP
      link
      fedilink
      English
      arrow-up
      1
      ·
      1 year ago

      thank you very much for your config file, however on pasting it and running it, i get the error

      ERROR: The Compose file './docker-compose.yml' is invalid because:
      Unsupported config option for services.caddy: 'lemmy'
      
        • youpie_temp@reddthat.comOP
          link
          fedilink
          English
          arrow-up
          1
          ·
          1 year ago

          thank you, the config now runs, unfortunately i am now getting a bad gateway when visiting the website. Also in the logs i see two errors that catch my eye thread 'main' panicked at 'Failed to load settings file, see documentation (https://join-lemmy.org/docs/en/administration/configuration.html): LemmyError { message: None, inner: Is a directory (os error 21), context: SpanTrace [] }', crates/utils/src/settings/mod.rs:20:20 and caddy_1 | {"level":"error","ts":1688725909.314515,"logger":"http.acme_client","msg":"challenge failed","identifier":"lemmy.emphisia.nl","challenge_type":"http-01","problem":{"type":"","title":"","detail":"","instance":"","subproblems":[]}}

          Also according to portainer, no ports are open on the caddy server. I have never used caddy. Thank you btw for trying to help me :))

          • Andreas
            link
            fedilink
            English
            arrow-up
            1
            ·
            edit-2
            1 year ago

            Oh shit, I forgot that your Caddy would be running on a bridge network by default because mine is on the host network where all ports are already exposed to it! (It’s generally a bad idea to use the host network, so don’t do this if you’re only using Caddy with containers on the same network) I edited the Gist to expose 80 and 443 for HTTP/S on that container, the updated file uses the same Github link. Really sorry about that!

            • youpie_temp@reddthat.comOP
              link
              fedilink
              English
              arrow-up
              1
              ·
              1 year ago

              I actually need the website to be hosted at 8085, as the nginx reverse proxy is listening at that adres, and it has already bound to port 80 and 443. When i open internal port 80 to 8085 and set the lemmy port to 8086 in the compose file. when i then visit the site i get a redirect loop. (im probably doing something horribly wrong). Also lemmy keeps panicking

              • Andreas
                link
                fedilink
                English
                arrow-up
                1
                ·
                edit-2
                1 year ago

                Why do you have to use NGINX? Caddy does the proxying to the Lemmy containers for you. That docker-compose.yml file is my entire deployment, there is no hidden NGINX container or config file that needs to be added. Just remove your broken Lemmy deployment with docker compose down and delete the containers, then docker compose up my docker-compose.yml (after you edit the postgres variables) with config.hjson in the same folder.

                • youpie_temp@reddthat.comOP
                  link
                  fedilink
                  English
                  arrow-up
                  1
                  ·
                  edit-2
                  1 year ago

                  hi, apologies for the incredibly late response, i was on vacation. So as per the setup guide of lemmy. i am using two nginx instances. one i a lemmy internal nginx, running in a container which uses the nginx-internal config file. This exposes lemmy on port 8085. i then want to use a reverse proxy so that i can access the website on lemmy.emphisia.nl for that i use a second nginx running on the host machine. this one is the reverse proxy for all services i have running on the machine. (nextcloud, onlyoffice, bitmanager and lemmy)