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

[2.2.0-rc2] kubernetes/ingress: bare host failed match on HTTP #6501

Closed
kardianos opened this issue Mar 16, 2020 · 9 comments · Fixed by #6504
Closed

[2.2.0-rc2] kubernetes/ingress: bare host failed match on HTTP #6501

kardianos opened this issue Mar 16, 2020 · 9 comments · Fixed by #6504
Assignees
Labels
area/provider/k8s/ingress kind/bug/confirmed a confirmed bug (reproducible). priority/P1 need to be fixed in next release status/5-frozen-due-to-age
Projects
Milestone

Comments

@kardianos
Copy link

kardianos commented Mar 16, 2020

Bug

What did you do?

Configure HTTP and HTTPS endpoints with middleware chain to redirect http to https.

What did you expect to see?

Redirect HTTP to HTTPS in all situations, including no or bare "/" path.

What did you see instead?

Without any path "" or maybe "/", the route "GET http://sub.domain" would fail to redirect to "https://sub.domain". It would just stop with a 404.

Output of traefik version: (What version of Traefik are you using?)

Version:      2.2.0-rc2
Codename:     chevrotin
Go version:   go1.14
Built:        2020-03-11T17:42:16Z
OS/Arch:      linux/amd64

What is your environment & configuration (arguments, toml, provider, platform, ...)?

Static configuration through environment for endpoints and Kubernets Ingress and Kubernetes CRD setup. Kubernetes configuration for dynamic configuration for routes.

Kubernetes Ingress and KubernetesCRD, configured outside of the cluster.

If applicable, please paste the log output in DEBUG level (--log.level=DEBUG switch)

Nothing applicable in DEBUG level log.


I'm using the newly (re-)introduced Kubernetes Ingress (not IngressRoute) for my main configuration for various reasons. I'm also using a Middleware chain that is redirecting http to https and non-www to www sub-domains (plus header addition, etc). Appears to work well.

When testing certain bare HTTP sub-domains, I found traefik would return a 404 before it even encountered the middleware. Testing was complicated due to HSTS header. But for example I found: GET http://qa.mydomain.com -> 404 (middleware not encountered) while http://qa.mydomain/anything -> 200 using middleware. I was able to use the jaeger integration to determine if the middle was was encountered at all.

I manually resolved this by creating Kubernetes IngressRoutes that bound directly on the HTTP endpoint only, used the same middleware, and only matched on the host, no Path or PathPrefix. This corrected the behavior to the desired behavior.

I suspect this has to do with how a Kubernetes Ingress object is internally represented + how HTTP (non-TLS) traffic paths are handled. Traefik creates to rules for Kubernetes Ingress objects: Host and PathPrefix. I suspect that internally the Request.URL.Path is either "/" or "" (empty) for this request either incoming or after processing. Then the created PathPrefix(/) rule doesn't match. This only appears to happen on HTTP, not HTTPS.

@traefiker

This comment has been minimized.

@rhzs

This comment has been minimized.

@ldez ldez self-assigned this Mar 17, 2020
@ldez ldez added this to issues in v2 via automation Mar 17, 2020
@ldez ldez mentioned this issue Mar 17, 2020
2 tasks
@ldez
Copy link
Member

ldez commented Mar 17, 2020

@traefiker
Copy link
Contributor

Closed by #6504.

@traefiker traefiker added this to the 2.2 milestone Mar 18, 2020
v2 automation moved this from issues to Done Mar 18, 2020
@dtomcej dtomcej linked a pull request Mar 18, 2020 that will close this issue
2 tasks
@travisghansen
Copy link

@ldez I just got around to trying this out and the experience is still less than ideal :( now none of my ingresses have tls on them by default.

@ldez
Copy link
Member

ldez commented Mar 25, 2020

@travisghansen
Copy link

@ldez ah, that helps. I'll do some more testing for a bit.

As an FYI the cli params did not work per the example in the doc:

  • --entrypoints.websecure.http.tls={} = failure
  • --entrypoints.websecure.http.tls=true = success

@ldez
Copy link
Member

ldez commented Mar 25, 2020

--entrypoints.websecure.http.tls={} is not a valid flag and this is not documented like that

You have to click on the CLI tabs: https://docs.traefik.io/v2.2/migration/v2/#kubernetes-ingress

If you want to talk more, could you go to the forum, thank you.

@travisghansen
Copy link

@ldez ah, thanks yet again! Overall this is looking much better (on rc4 atm)! I'll dig through several more scenarios and get even deeper into testing now that the basics are out of the way.

@traefik traefik locked and limited conversation to collaborators Mar 25, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area/provider/k8s/ingress kind/bug/confirmed a confirmed bug (reproducible). priority/P1 need to be fixed in next release status/5-frozen-due-to-age
Projects
No open projects
v2
Done
Development

Successfully merging a pull request may close this issue.

5 participants