-
Notifications
You must be signed in to change notification settings - Fork 44
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
How to use EAS with Traefik IngressRoute CRD? #131
Comments
You need a Middleware for this:
and use this in your IngressRoute:
|
Been meaning to add a traefik 2 example. We’ll get one added to the docs. |
Thank you for your response. We have tested this, but are seeing some issues with how the redirect is handled. From the logs, we are seeing the following (hostname redacted): {"service":"external-auth-server","level":"verbose","message":"parent request info: {\"uri\":\"https://app.hostname.comundefined\",\"parsedUri\":{\"scheme\":\"https\",\"host\":\"eas.hostname.comundefined\",\"path\":\"\",\"reference\":\"absolute\"},\"parsedQuery\":{}}"} Furthermore, the URL in the webbrowser also has the
|
Ref. It happens because
|
I had this problem a while ago, too - before I set x-forwarded-uri - then it disappeared. |
Agreed. Although in the pre reqs it is mentioned this is a must. Without setting it (to a proper value) there could be adverse effects. Is traefik not sending it at all? Or simply not setting it when the path is the root path? |
From the logs we can't see any We tried to follow the HOWTO.md document as close as possible, but had to modify it to use the IngressRoute CRD |
Interesting. Let me fire this up locally and do a little testing. What exact version of traefik are you running? |
Traefik 2.4.13 |
I think I may know what's going on here, but need more info to be sure. In your config you have this: Is that going directly to |
Here is our configTokenSignSecret: "${config_token_sign_secret}"
configTokenEncryptSecret: "${config_token_encrypt_secret}"
issuerSignSecret: "${issuer_sign_secret}"
issuerEncryptSecret: "${issuer_encrypt_secret}"
cookieSignSecret: "${cookie_sign_secret}"
cookieEncryptSecret: "${cookie_encrypt_secret}"
sessionEncryptSecret: "${session_encrypt_secret}"
logLevel: "silly"
redis-ha:
enabled: false
image:
repository: hostname.azurecr.io/external-auth-server
tag: "test-3"
pullPolicy: IfNotPresent
ingress:
enabled: false We are using a Traefik |
OK, is there any way you can point the middleware directly to the k8s internal service instead of through an Ingress/IngressRoute? To give some context: client -> traefik (actual service) -> traefik (eas) I believe what's happening is the traefik in front of eas is actually stripping the headers (that get added by the traefik from the actual service). You can bypass traefik fronting eas entirely (in the context of the Set the In short |
What I forgot to mention: I had to set trustedIPs, to make it work, since my eas indeed is behind traefik. |
For setting it as an forward auth url I would recommend using the internal service endpoint to avoid the overhead and issues. However, I would also expose it externally using ingress/crd so that sso can be used by setting cookie domain and/or static callback url endpoint. |
Good evening, Sorry about the late response - modifying the traefik config caused our SSL certificates to be renewed excessively, which in turn lead to us getting rate-limited by letsencrypt. Oops.. DEV-cluster only, so no real harm done :) After solving the SSL-issue (also implementing persistance), we have added the changes you suggested. We added the AKS pod and service CIDR to Not sure why, but the Traefik middleware appear to want to redirect to port |
Bad logic in |
Seems I was tricked by the Firefox cache. Sorry about the confusion. We were finally able to get the middleware to direct to the correct service ( Will let keep you updated as we progress |
The changes @travisghansen and @kettenbach-it suggested does in indeed work. Quick summary: First of all, we have deployed Traefik (version additionalArguments:
- "--certificatesresolvers.letsencrypt.acme.tlschallenge=true"
- "--certificatesresolvers.letsencrypt.acme.email=${letsencrypt_email}"
- "--certificatesresolvers.letsencrypt.acme.storage=/data/acme.json"
- "--certificatesresolvers.letsencrypt.acme.caserver=https://acme-v02.api.letsencrypt.org/directory"
- "--api.insecure=true"
- "--entrypoints.web.http.redirections.entryPoint.to=websecure"
- "--entryPoints.websecure.forwardedHeaders.trustedIPs=127.0.0.1,10.244.0.0/16,10.0.0.0/16"
- "--serverstransport.insecureskipverify=true"
deployment:
initContainers:
# The "volume-permissions" init container is required if you run into permission issues.
# Related issue: https://github.com/containous/traefik/issues/6972
- name: volume-permissions
image: busybox:1.31.1
command: ["sh", "-c", "chmod -Rv 600 /data"]
volumeMounts:
- name: data
mountPath: /data
logs:
general:
level: INFO
access:
enabled: true
persistence:
enabled: true
accessMode: ReadWriteMany
storageClass: ssl-certificates Do note that we have set We have also used Helm to deploy EAS. Following is our configTokenSignSecret: "${config_token_sign_secret}"
configTokenEncryptSecret: "${config_token_encrypt_secret}"
issuerSignSecret: "${issuer_sign_secret}"
issuerEncryptSecret: "${issuer_encrypt_secret}"
cookieSignSecret: "${cookie_sign_secret}"
cookieEncryptSecret: "${cookie_encrypt_secret}"
sessionEncryptSecret: "${session_encrypt_secret}"
redis-ha:
enabled: false
ingress:
enabled: false Note that we have used a Traefik The middleware is basically the same as the one provided by @kettenbach-it: **apiVersion: traefik.containo.us/v1alpha1
kind: Middleware
metadata:
name: my-middleware-name
namespace: mynamespace
spec:
forwardAuth:
address: "https://eas.myhost.com/verify?config_token_store_id=default&config_token_id=whatever"
trustForwardHeader: true
authResponseHeaders:
- X-Forwarded-User
- X-Forwarded-Uri
- X-Id-Token
- X-Userinfo
- X-Access-Token
- Authorization The same is also the case for the apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
name: my-route
namespace: mynamespace
spec:
entryPoints:
- websecure
routes:
- match: Host(`app.myhost.com`) # Hostname to match
kind: Rule
middlewares:
- name: my-middleware-name
namespace: mynamespace
services:
- name: myservice
port: 80
tls:
certResolver: letsencrypt
domains:
- app.myhost.com |
Looks great! Back to the original ask, I’ll probably add some code that throws an error instead of behaving badly as it does now. |
awesome, thank you! @sseppola is also working on a PR for you |
I have added more strict handling of this issue: b26a1a2 If the necessary headers are not present it now throws an error. |
Hi there!
We are looking to use EAS with an IngressRoute CRD.
This achievable, and if so, how?
The text was updated successfully, but these errors were encountered: