Skip to content

Unable to redirect to the original host #114

@adrdra

Description

@adrdra

Hello there!

I am trying to use this project instead of https://github.com/thomseddon/traefik-forward-auth. I succeed to do the connection with my oauth provider, but I am always been redirected to the auth host instead of the origin host.

I have:

  1. traefik as reverse proxy
  2. A web service
  3. A traefik-auth running on the current project

I need to protect some routes of my web service with traefik-auth.

Current Behavior

When accessing a protected endpoint (e.g., service.example.com/health), the authentication flow incorrectly redirects users to oauth.example.com/health after successful authentication instead of returning to the original URL.

Expected Behavior

After successful OAuth authentication, users should be redirected back to their original requested URL:

  1. Initial request to service.example.com/health
  2. Redirect to OAuth provider for authentication
  3. Return to auth callback endpoint
  4. Final redirect back to service.example.com/health

Configuration

  1. traefik-auth
services:
  traefik-auth:
    build:
      context: .
      dockerfile: Dockerfile
    env_file: .env
    depends_on:
      - traefik
    labels:
      - traefik.enable=true
      - traefik.http.routers.traefik-auth-tls.entrypoints=https
      - traefik.http.routers.traefik-auth-tls.tls=true
      - traefik.http.routers.traefik-auth-tls.rule= Host(`oauth.example.com`)
      - traefik.http.routers.traefik-auth.entrypoints=http
      - traefik.http.services.traefik-auth.loadbalancer.server.port=4181
      - traefik.http.middlewares.forward-auth.forwardauth.address=http://traefik-auth:4181
      - traefik.http.middlewares.forward-auth.forwardauth.trustForwardHeader=true
      - traefik.http.middlewares.forward-auth.forwardauth.authResponseHeaders=X-Forwarded-User
      - traefik.http.routers.traefik-auth-tls.middlewares=forward-auth
  1. service
services:
  service:
    build:
      context: .
      dockerfile: Dockerfile
    env_file: env
    depends_on:
      - postgres
      - traefik
    labels:
      - traefik.enable=true
      - traefik.http.routers.service.entrypoints=http
      - traefik.http.routers.service-tls.entrypoints=https
      - traefik.http.routers.service-tls.tls=true
      - traefik.http.routers.service.middlewares=forward-auth

Thanks for your help.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions