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

Infinite redirect #158

Closed
maxisme opened this issue Jul 31, 2020 · 7 comments
Closed

Infinite redirect #158

maxisme opened this issue Jul 31, 2020 · 7 comments

Comments

@maxisme
Copy link

maxisme commented Jul 31, 2020

Hey I am getting an infinite loop after authorising when visiting whoami.$DOMAIN

this is my swarm stack.yml for traefik-forward-auth:

  traefik-forward-auth:
    image: thomseddon/traefik-forward-auth
    environment:
      - DEFAULT_PROVIDER=generic-oauth
      - "PROVIDERS_GENERIC_OAUTH_AUTH_URL=${PROVIDERS_GENERIC_OAUTH_AUTH_URL:?err}"
      - "PROVIDERS_GENERIC_OAUTH_TOKEN_URL=${PROVIDERS_GENERIC_OAUTH_TOKEN_URL:?err}"
      - "PROVIDERS_GENERIC_OAUTH_USER_URL=${PROVIDERS_GENERIC_OAUTH_USER_URL:?err}"
      - "PROVIDERS_GENERIC_OAUTH_CLIENT_ID=${PROVIDERS_GENERIC_OAUTH_CLIENT_ID:?err}"
      - "PROVIDERS_GENERIC_OAUTH_CLIENT_SECRET=${PROVIDERS_GENERIC_OAUTH_CLIENT_SECRET:?err}"
      - "SECRET=${OAUTH_SECRET:?err}"
      - "COOKIE_DOMAIN=${DOMAIN}"
      - "AUTH_HOST=auth.${DOMAIN}"
      - "LOG_LEVEL=trace"
    networks:
      - traefik
    deploy:
      labels:
        - "traefik.enable=true"
        - "traefik.http.routers.traefik-forward-auth.rule=Host(`auth.${DOMAIN}`)"
        - "traefik.http.routers.traefik-forward-auth.entrypoints=web-secure"
        - "traefik.http.routers.traefik-forward-auth.tls.certresolver=letsencrypt"
        - "traefik.http.services.traefik-forward-auth.loadbalancer.server.port=4181"
        - "traefik.http.middlewares.traefik-forward-auth.forwardauth.address=http://traefik-forward-auth:4181"
        - "traefik.http.middlewares.traefik-forward-auth.forwardauth.authResponseHeaders=X-Forwarded-User"
      placement:
        constraints: [node.role == manager]

And this the whoami service:

  whoami:
    # A container that exposes an API to show its IP address
    image: containous/whoami
    networks:
      - traefik
    deploy:
      mode: global
      labels:
        - "traefik.enable=true"
        - "traefik.http.routers.whoami.rule=Host(`whoami.${DOMAIN:?err}`)"
        - "traefik.http.routers.whoami.service=whoami"
        - "traefik.http.routers.whoami.entrypoints=web-secure"
        - "traefik.http.routers.whoami.tls.certresolver=letsencrypt"
        - "traefik.http.services.whoami.loadbalancer.server.port=80"
        - "traefik.http.routers.whoami.middlewares=traefik-forward-auth"
@maxisme
Copy link
Author

maxisme commented Jul 31, 2020

My Authorization callback URL on github is https://auth.${DOMAIN}

@maxisme
Copy link
Author

maxisme commented Jul 31, 2020

Solution was to add to the traefik-forward-auth labels:

- "traefik.http.routers.traefik-forward-auth.middlewares=traefik-forward-auth"

Would you be able to put that in the documentation?

@sodennis
Copy link

sodennis commented Jan 4, 2021

 - "traefik.http.routers.traefik-forward-auth.middlewares=traefik-forward-auth"

For others who are encountering this issue, add the above line to the traefik-forward-auth container.

@Federerer
Copy link

I've wasted an hour on this 🙄

@Andreychik32
Copy link

@thomseddon, you should add this to docs.

 - "traefik.http.routers.traefik-forward-auth.middlewares=traefik-forward-auth"

For others who are encountering this issue, add the above line to the traefik-forward-auth container.

I've wasted almost 3 hours until I found this.

@edorgeville
Copy link

I've wasted less than 10 minutes because I went to the issue tracker right away 🤣

@NishikaDeSilva
Copy link

I'm still getting an infinite loop. I made some changes to middleware as below since http://traefik-forward-auth:4181 didn't work for me at all.

apiVersion: traefik.containo.us/v1alpha1
kind: Middleware
metadata:
  name: traefik-forward-auth
spec:
  forwardAuth:
    address: https://auth.${DOMAIN}
    authResponseHeaders:
      - X-Forwarded-User

Any help is appreciated.
I also tried added middleware to route, but that didn't even forwarded to google auth.

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

No branches or pull requests

6 participants