Closed wardwygaerts closed 1 month ago
Hmmm... This is strange, can you send your docker compose file so I can try and debug on my PC? Thanks!
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: {}
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.
Yes, that is true. There are some ways to test it.
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.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 addressPUBLIC_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!
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.
@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!
I have it working with my Traefik setup (was not able to get it work locally). Everything seems to be working, except the flags:
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
@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!
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
@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`)
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
@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 :)
I changed the URL of my nginx container to be
flags.domain.com
and setPUBLIC_URL
toflags.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?
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: