-
Notifications
You must be signed in to change notification settings - Fork 8.4k
Question: why the case insensitive regular expression location modifier will be enforced on ALL paths If the use-regex is set #11397
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
Comments
This issue is currently awaiting triage. If Ingress contributors determines this is a relevant issue, they will accept it by applying the The Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
Because, IIRC, we also have a check for multiple Ingress resources with the same hostname and do not allow them. I'm not 100% sure about this, but if we do have it, then this would mean you can't define another Ingress resource without |
Maybe I didn't understand correctly, but we do have multiple Ingress resources with the same hostname and it works completely fine. |
But even if it's the case. Why turn While being "expected" behavior it's definitely confusing |
A small example to illustrate. If you define two ingresses using the same host header and the one ingress is ImplementationSpecific and has the annotation
Then the default nginx.tmpl rendering will create a config that looks like
And both of the location directives have converted into a regex match - this means that the Exact Pathtype But with the patch we are applying to the nginx.tmpl we get
Notice that And we/I just cannot understand why this would not be the default behaviour (or maybe have an option for it) |
ANY annotation from an ingress, applies to the entire ingress and the impact of the annotation is not limited to just one single path, configured in the ingress. Or so I had assumed AFAIK. I did not think that only the The server-block that all that annotations apply to are the server from the The location blocks inside the server block are from the When multiple ingress resources have the same value for the Following above 3 assumptions, what you are experiencing seems consistent with expected behavior. I guess you are expecting that this Your expectation seems fair. If I am not wrong some other people have also reported this, in other issues. And yet there are lots of users who have not reported this problem so I guess they do not have the same use case and/or same conflict of interest with prioritization of the location blocks. I too will wait for comments and thoughts on this. It will be interesting to learn, how one annotation should NOT apply to all the paths. |
/assign |
While we use a template to work-around this behavior it'd be better to change the actual If you want I can try to prepare a PR that would make it behave the way that would make more sense (IMO). There're two possibilities:
Edit: Also one point in favor of implementing 2 is that it would make the most sense for |
Without being a developer, I can just opine that it will not be easy to change the go code behavior, if that go code is generic code path for all annotations. If You want the generic go code to behave differently, just for the But all that is assumption so we just wait for other comments. |
It's actually not. It's a special case only for the |
@arkberezkin thank you for that info. It helps a lot I think. We have to wiat for comments from others. |
This is stale, but we won't close it automatically, just bare in mind the maintainers may be busy with other tasks and will reach your issue ASAP. If you have any question or request to prioritize this, please reach |
This appears to still be a problem, and I'm happy to submit an PR to address it. The
Notice that the enforceRegex condition is checked first, before checking if the location is exact. It seems like switching the order of these two checks, so the check for Exact happens first, would address this problem, without changing any of the regex logic. Is there some reason why these checks happen in the order they do today? |
@dacohen We’ve also encountered a similar issue. Although we can work around it using regex, we still hope that this behavior can be fixed directly. I think your method is feasible. |
From the ingress-nginx doc https://kubernetes.github.io/ingress-nginx/user-guide/ingress-path-matching/#warning
My question is why? why does it have to be this way? why can't it just be the ingress that has "use-regex=true" or "rewrite-target" defined that uses case insensitive regular expression locations match.
We have a very old website with some not so well designed paths like
/[a-z0-9_.-]{3,40}(\/)?([\?\#]|$)
And when we add that as an ingress and sets the annotation use-regex=true then all the Exact and Prefix ingress are all converted into case insensitive regular expression location modifiers and we loose that ability to have a simple prioritisation.
Like having a Prefix ingress for path /foo that will have a higher priority than the regex above.
And we cannot for the life in us understand why anyone would want this default behaviour, that if one ingress is using regex then all is converted into regex location matches.
We have to patch the nginx.tmpl to get around this
This is our patch and it works fine for us but maybe we are missing something (most likely we are, hence why I'm asking this question)
With this patch an Exact ingress type will not be changed into case insensitive regular expression location modifiers but remain "=" location modifier.
Simon Ellefsen
The text was updated successfully, but these errors were encountered: