seanmorley15 / AdventureLog

Self-hostable travel tracker and trip planner.
https://adventurelog.app
Other
550 stars 14 forks source link

Registration is disabled #294

Closed wardwygaerts closed 1 month ago

wardwygaerts commented 1 month ago

Although I didn't set the variable to disable registration, I get the following message in the logs and I'm not able to signup:

05-09-2024 22:29:40 The origin to be set is: http://localhost:9866
05-09-2024 22:29:40 Listening on 0.0.0.0:3000
05-09-2024 22:30:18 {
05-09-2024 22:30:18   is_disabled: false,
05-09-2024 22:30:18   message: 'Registration is disabled. Please contact the administrator if you need an account.'
05-09-2024 22:30:18 }
05-09-2024 22:30:18 []
05-09-2024 22:30:18 { user: null, is_disabled: false }
seanmorley15 commented 1 month ago

Hmmm... This is strange, can you send your docker compose file so I can try and debug on my PC? Thanks!

wardwygaerts commented 1 month ago

All settings are the defaults one I think, I first wanted to get it running before I integrate it in my Traefik setup.

services:
  web:
    container_name: adventurelog-frontend
    image: ghcr.io/seanmorley15/adventurelog-frontend:latest
    hostname: adventurelog-frontend
    environment:
      - PUBLIC_SERVER_URL=http://server:8000 # MOST DOCKER USERS WILL NEVER NEED TO CHANGE THIS, EVEN IF YOU CHANGE THE PORTS
      - ORIGIN=http://localhost:9866
      - BODY_SIZE_LIMIT=Infinity # This is measured in bytes
    ports:
      - 9866:3000
    depends_on:
      - server
  db:
    container_name: adventurelog-db
    image: postgis/postgis:15-3.3
    hostname: adventurelog-db
    mem_limit: 1g
    cpu_shares: 1024
    environment:
      POSTGRES_DB: adventurelog
      POSTGRES_USER: adventureloguser
      POSTGRES_PASSWORD: adventurelogpass
    volumes:
      - $CONFIGDIR/adventurelog/db:/var/lib/postgresql/data/
    healthcheck:
      test:
        - CMD
        - pg_isready
        - -q
        - -d
        - adventurelog
        - -U
        - adventureloguser
      timeout: 45s
      interval: 10s
      retries: 10
    restart: unless-stopped
  server:
    container_name: adventurelog-backend
    image: ghcr.io/seanmorley15/adventurelog-backend:latest
    hostname: adventurelog-backend
    environment:
      - PGHOST=db
      - PGDATABASE=adventurelog
      - PGUSER=adventureloguser
      - PGPASSWORD=adventurelogpass
      - SECRET_KEY=GesRc2FG3Hnzujz5WAAjGHBc3pm7
      - DJANGO_ADMIN_USERNAME=admin
      - DJANGO_ADMIN_PASSWORD=admin
      - DJANGO_ADMIN_EMAIL=email@email.com
      - PUBLIC_URL='http://server:81'
      - CSRF_TRUSTED_ORIGINS=https://api.adventurelog.app,https://adventurelog.app
      - DEBUG=False
      - FRONTEND_URL='http://localhost:9866'
    ports:
      - 8669:8000
    depends_on:
      - db
    volumes:
      - $CONFIGDIR/adventurelog/server:/code/media/
  nginx:
    container_name: adventurelog-web
    image: nginx:latest
    ports:
      - 81:80
    healthcheck:
      test: timeout 10s bash -c ':> /dev/tcp/127.0.0.1/80' || exit 1
      interval: 10s
      timeout: 5s
      retries: 3
      start_period: 90s
    volumes:
      - $CONFIGDIR/adventurelog/server:/app/media
      - $CONFIGDIR/adventurelog/web/nginx.conf:/etc/nginx/conf.d/default.conf:ro
    depends_on:
      - server
networks: {}
n00b12345 commented 1 month ago

Hi @wardwygaerts

I was facing the same issue. Please change the URL address in your docker-compose where you have included "localhost" to your server name (say "ubuntu-pc"). This will solve the issue.

seanmorley15 commented 1 month ago

Yes, that is true. There are some ways to test it.

  1. If you go to https://api.adventurelog.app/auth/is-registration-disabled/ replacing with you backend domain, it should tell you if registration is disabled. Although this is likely a server connection issue because it queries this when the registration page is opened.
  2. ORIGIN=http://localhost:9866 - if this is not the address you are accessing from, it will bring up a cross site post error. Ensure you only access this app from this address
  3. PUBLIC_URL='http://server:81' this should be the public address to the nginx container, it should be accessible where you access your app. This is used for images.

I hope this helps!

n00b12345 commented 1 month ago

Hello @seanmorley15

Is it possible to self host adventure log without a fully qualified domain name? I am only going to use this for personal use and will be using Tailscale to connect to it remotely.

seanmorley15 commented 1 month ago

@n00b12345 Yes!, I do not know much about tailscale but I use it all the time myself with localhost on my network. I would assume that to use tailscale you would have to update some variables like ORIGIN and other URL based things in the documentation. Let me know if you have any questions!

wardwygaerts commented 1 month ago

I have it working with my Traefik setup (was not able to get it work locally). Everything seems to be working, except the flags: image

url of the images: https://adventurelog.domain.com/media/flags/**.png I added the nginx.conf file.

nginx compose:

nginx:
    container_name: adventurelog-web
    image: nginx:latest
    networks:
      - proxy
    ports:
      - 81:80
    healthcheck:
      test: timeout 10s bash -c ':> /dev/tcp/127.0.0.1/80' || exit 1
      interval: 10s
      timeout: 5s
      retries: 3
      start_period: 90s
    volumes:
      - $CONFIGDIR/adventurelog/web:/usr/share/nginx/html
      - $CONFIGDIR/adventurelog/media:/app/media/
      - $CONFIGDIR/adventurelog/web/nginx.conf:/etc/nginx/conf.d/default.conf:ro
    labels:
      - traefik.enable=true
      - traefik.http.routers.adventurelog-nginx-rtr.entrypoints=https
      - traefik.http.routers.adventurelog-nginx-rtr.rule=Host(`adventurelog.$DOMAINNAME`)
        && PathPrefix(`/media`)
      - traefik.http.routers.adventurelog-nginx-rtr.tls=true
      - traefik.http.routers.adventurelog-nginx-rtr.middlewares=chain-oauth@file
      - traefik.http.routers.adventurelog-nginx-rtr.service=adventurelog-nginx-svc
      - traefik.http.services.adventurelog-nginx-svc.loadbalancer.server.port=3000
      - traefik.http.middlewares.adventurelog-nginx-strip.stripprefix.prefixes=/media
    depends_on:
      - server
seanmorley15 commented 1 month ago

@wardwygaerts, sorry for the delay. The issue with the images not working is most likely a result of the PUBLIC_URL in the backend not being set to the publicly accessible url to the nginx container. You should be able to access nginx from this url where you access your app to ensure the images are displayed. I hope this helps!

wardwygaerts commented 1 month ago

The PUBLIC_URL is set to the url which I use to access adventurelog.

I now get a 404 when opening a url of a flag.

full compose file:

services:
  web:
    container_name: adventurelog-frontend
    image: ghcr.io/seanmorley15/adventurelog-frontend:latest
    hostname: adventurelog-frontend
    environment:
      - PUBLIC_SERVER_URL=http://adventurelog-backend:8000 # MOST DOCKER USERS WILL NEVER NEED TO CHANGE THIS, EVEN IF YOU CHANGE THE PORTS
      - ORIGIN=https://adventurelog.$DOMAINNAME
      - BODY_SIZE_LIMIT=Infinity # This is measured in bytes
    ports:
      - 9866:3000
    networks:
      - proxy
      - local
    labels:
      - traefik.enable=true
      - traefik.http.routers.adventurelog-rtr.entrypoints=https
      - traefik.http.routers.adventurelog-rtr.rule=Host(`adventurelog.$DOMAINNAME`)
        && !PathPrefix(`/media`)
      - traefik.http.routers.adventurelog-rtr.tls=true
      - traefik.http.routers.adventurelog-rtr.middlewares=chain-oauth@file
      - traefik.http.routers.adventurelog-rtr.service=adventurelog-svc
      - traefik.http.services.adventurelog-svc.loadbalancer.server.port=3000
    depends_on:
      - server
  db:
    container_name: adventurelog-db
    image: postgis/postgis:15-3.3
    hostname: adventurelog-db
    networks:
      - local
    environment:
      POSTGRES_DB: adventurelog
      POSTGRES_USER: adventureloguser
      POSTGRES_PASSWORD: adventurelogpass
    volumes:
      - $CONFIGDIR/adventurelog/db:/var/lib/postgresql/data/
    restart: unless-stopped
  server:
    container_name: adventurelog-backend
    image: ghcr.io/seanmorley15/adventurelog-backend:latest
    hostname: adventurelog-backend
    environment:
      - PGHOST=db
      - PGDATABASE=adventurelog
      - PGUSER=adventureloguser
      - PGPASSWORD=adventurelogpass
      - SECRET_KEY=GesRc2FG3Hnzujz5WAAjGHBc3pm7
      - DJANGO_ADMIN_USERNAME=admin
      - DJANGO_ADMIN_PASSWORD=admin
      - DJANGO_ADMIN_EMAIL=mail@gmail.com
      - PUBLIC_URL=https://adventurelog.$DOMAINNAME
      - CSRF_TRUSTED_ORIGINS=https://api.adventurelog.app,https://adventurelog.app,https://adventurelog.$DOMAINNAME
      - DEBUG=False
      - FRONTEND_URL=https://adventurelog.$DOMAINNAME
    ports:
      - 8669:8000
    networks:
      - local
    depends_on:
      - db
    volumes:
      - $CONFIGDIR/adventurelog/media:/code/media/
  nginx:
    container_name: adventurelog-web
    image: nginx:latest
    networks:
      - proxy
      - local
    ports:
      - 8099:80
    volumes:
      - $CONFIGDIR/adventurelog/media:/usr/share/nginx/html
    labels:
      - traefik.enable=true
      - traefik.http.routers.advnginx-rtr.entrypoints=websecure
      - traefik.http.routers.advnginx-rtr.rule=Host(`adventurelog.$DOMAINNAME`)
        && !PathPrefix(`/media`)
      - traefik.http.routers.advnginx-rtr.tls=true
      - traefik.http.routers.advnginx-rtr.service=advnginx-svc
      - traefik.http.services.advnginx-svc.loadbalancer.server.port=80
      - traefik.http.middlewares.advnginx-stripprefix.stripprefix.prefixes=/media
      - traefik.http.routers.advnginx.middlewares=advnginx-stripprefix
    depends_on:
      - server
networks:
  proxy:
    external: true
  local:
    external: true
seanmorley15 commented 1 month ago

@wardwygaerts, after doing some research, I would try this: Ensure you DO NOT have this middleware because you want to keep the /media prefix, just forward to the nginx container.

#- traefik.http.middlewares.advnginx-stripprefix.stripprefix.prefixes=/media
#- traefik.http.routers.advnginx-rtr.middlewares=advnginx-stripprefix

then change the line that currently excludes the media route to include it:

- traefik.http.routers.advnginx-rtr.rule=Host(`adventurelog.$DOMAINNAME`) && PathPrefix(`/media`)
ranasats commented 1 month ago

I have a fix for this that is slightly unconventional.

I changed the URL of my nginx container to be flags.domain.com and set PUBLIC_URL to flags.domain.com, and it works perfectly. I removed all of the traefik pathprefix configuration since that did not work for me at all. So for example, my flags now sit like this:

https://flags.domain.com/media/flags/af.png

and it looks fine on my main trips.domain.com

seanmorley15 commented 1 month ago

@ranasats, glad its working now! This seems to be a normal configuration because the PUBLIC_URL should just point to the nginx container. Its kind of confusing but its mainly because Django unfortunately does not serve media in production mode.

Let me know if you have any other questions :)

wardwygaerts commented 1 month ago

I changed the URL of my nginx container to be flags.domain.com and set PUBLIC_URL to flags.domain.com

This worked for me too! Actually this seems logic, but did not thought about it. Maybe specify this in the doker-compose example?