gotify / server

A simple server for sending and receiving messages in real-time per WebSocket. (Includes a sleek web-ui)
https://gotify.net
Other
10.43k stars 593 forks source link

Cannot login behind Traefik, but ip:port works fine #639

Closed joshoram80 closed 3 months ago

joshoram80 commented 3 months ago

Have you read the documentation?

You are setting up gotify in

Describe your problem

Cannot login when accessing Gotify via Traefik, but login via IP:Port Works fine. Obviously this is not ideal

2024-03-15T19:43:15+11:00 | 401 | 24.478µs | 202.179.131.174 | POST "/client" Error #01: you need to provide a valid access token or user credentials to access this api

Ex: docker-compose.yml, nginx.conf, android logcat, browser requests, etc.

Compose Snippet

gotify:
    image: ghcr.io/gotify/server:latest
    container_name: gotify
    restart: unless-stopped
    networks:
      - t2_proxy
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=$TZ
    volumes:
      - $DOCKERDIR/appdata/gotify/data:/app/data
    ports:
      - 8044:80 #optional
    labels:
      - "traefik.enable=true"
      ## HTTP Local Auth Bypass
      - "traefik.http.routers.gotify-rtr-local.entrypoints=https"
      - "traefik.http.routers.gotify-rtr-local.rule=Host(`gotify.$DOMAINNAME`) && ClientIP(`192.168.0.0/24`)"
      - "traefik.http.routers.gotify-rtr-local.priority=100"
      - "traefik.http.routers.gotify-rtr-local.middlewares=middlewares-authentik@file"
      - "traefik.http.routers.gotify-rtr-local.service=gotify-svc"
      ## HTTP Routers
      - "traefik.http.routers.gotify-rtr.entrypoints=https"
      - "traefik.http.routers.gotify-rtr.rule=Host(`gotify.$DOMAINNAME`)"
      - "traefik.http.routers.gotify-rtr.priority=99"
      ## Middlewares
      - "traefik.http.routers.gotify-rtr.middlewares=middlewares-authentik@file"
      ## HTTP Services
      - "traefik.http.routers.gotify-rtr.service=gotify-svc"
      - "traefik.http.services.gotify-svc.loadbalancer.server.port=80"

The middleware in the snippet is just auth response headers for Authentik, nothing touches Basic Auth

jmattheis commented 3 months ago

show your middlewares-authentik@file.

joshoram80 commented 3 months ago

middlewares-authentik: forwardAuth: address: "http://authentik_server:9000/outpost.goauthentik.io/auth/traefik" trustForwardHeader: true authResponseHeaders:

jmattheis commented 3 months ago

You've listed authorization in the authResponseHeaders. Basic auth uses this header.

joshoram80 commented 3 months ago

Excellent! I Completely overlooked that. Thanks :D