Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ForwardAuth is not loading requested Path after successful authentication #323

Open
prutheus opened this issue Aug 9, 2022 · 0 comments · May be fixed by #335
Open

ForwardAuth is not loading requested Path after successful authentication #323

prutheus opened this issue Aug 9, 2022 · 0 comments · May be fixed by #335

Comments

@prutheus
Copy link

prutheus commented Aug 9, 2022

I want to use ForwardAuth to secure my traefik frontend, which I serve at mydomain.org/traefik:


services:
    traefik:
        image: traefik
        restart: always
        command:
            - "--providers.docker"
            - "--providers.docker.network=traefik"
            - "--entrypoints.web.address=:80"
            - "--entrypoints.websecure.address=:443"
            - "--certificatesresolvers.letsencryptresolver.acme.httpchallenge=true"
            - "--certificatesresolvers.letsencryptresolver.acme.httpchallenge.entrypoint=web"
            - "--certificatesresolvers.letsencryptresolver.acme.email=mail@mydomain.org"
            - "--certificatesresolvers.letsencryptresolver.acme.storage=/letsencrypt/acme.json"
            - "--entrypoints.web.http.redirections.entryPoint.to=websecure"
            - "--entrypoints.web.http.redirections.entryPoint.scheme=https"
            - "--api.dashboard=true"
            - "--accesslog=true"
        ports:
            - "80:80"
            - "443:443"
        volumes:
            - certificates:/letsencrypt
            - /var/run/docker.sock:/var/run/docker.sock:ro
        labels:
            - "traefik.http.routers.cloud-network-traefik.rule=Host(`mydomain.org`) && (PathPrefix(`/traefik`) || PathPrefix(`/api`))"
            - "traefik.http.routers.cloud-network-traefik.entrypoints=websecure"
            - "traefik.http.routers.cloud-network-traefik.tls.certresolver=letsencryptresolver"
            - "traefik.http.routers.cloud-network-traefik.service=api@internal"
            - "traefik.http.routers.cloud-network-traefik.middlewares=cloud-network-traefik-stripprefix,cloud-network-forwardauth"
            - "traefik.http.middlewares.cloud-network-traefik-stripprefix.stripprefix.prefixes=/traefik"
        networks:
            - traefik

    forwardauth:
        image: thomseddon/traefik-forward-auth
        restart: always
        environment:
            DEFAULT_PROVIDER: oidc
            PROVIDERS_OIDC_ISSUER_URL: https://id.mydomain.org/realms/auth
            PROVIDERS_OIDC_CLIENT_ID: cloud-network
            PROVIDERS_OIDC_CLIENT_SECRET: 123412341234
            SECRET: 8123412341234
        labels:
            - "traefik.http.routers.cloud-network-forwardauth.rule=Path(`/_oauth`)"
            - "traefik.http.routers.cloud-network-forwardauth.entrypoints=websecure"
            - "traefik.http.routers.cloud-network-forwardauth.tls.certresolver=letsencryptresolver"
            - "traefik.http.routers.cloud-network-forwardauth.tls=true"
            - "traefik.http.services.cloud-network-forwardauth.loadbalancer.server.port=4181"
            - "traefik.http.routers.cloud-network-forwardauth.middlewares=cloud-network-forwardauth"
            - "traefik.http.middlewares.cloud-network-forwardauth.forwardauth.address=http://forwardauth:4181"
            - "traefik.http.middlewares.cloud-network-forwardauth.forwardauth.authResponseHeaders=X-Forwarded-User,X-Auth-Request-Email,Set-Cookie,X-Auth-Request-Access-Token,Authorization,X-Auth-Request-Redirect"
            - "traefik.http.middlewares.cloud-network-forwardauth.forwardauth.trustForwardHeader=true"
        networks:
            - traefik

However, when I open https://mydomain.org/traefik I get redirected to my auth provider to sign in, and when done, I get redirected to https://mydomain.org instead of /traefik ... any ideas?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant