-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Regex in proxy-redirect-from and proxy-redirect-to #10698
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/test-infra repository. |
I can see from https://github.com/kubernetes/ingress-nginx/blob/main/internal/ingress/annotations/parser/validators.go#L62 and https://github.com/kubernetes/ingress-nginx/blob/main/internal/ingress/annotations/parser/validators.go#L44 , https://github.com/kubernetes/ingress-nginx/blob/main/internal/ingress/annotations/parser/validators.go#L47 that only The nginx documentation for the
So, is there a reason we're expecting a URL in here? Can we also accept a full regex with capture groups? |
|
/triage needs-information |
/remove-kind bug |
@longwuyuan Sorry, not sure what you meant. If I understood correctly, you want me to close this issue and open a new one using a template? Also, do not agree that this is not a bug. I still believe it is a bug, as the nginx configuration allows for something that is not being allowed via these annotations. The "allow snippet annotations" is not helpful, as one cannot disable via configuration that a |
Hi @suvl annotations:
nginx.ingress.kubernetes.io/proxy-redirect-from: '~*^.*\/\/pod-(?<pod_nr>\d+?)(\..*\.svc\.cluster\.local
)?(:\d*)?(?<pod_path>\/.*)?$'
nginx.ingress.kubernetes.io/proxy-redirect-to: "https://p-$pod_nr.project.example.com$pod_path" image version: ingress-nginx/controller:v1.6.4 |
Hey there @opencmit2, do you have controller:
extraArgs:
enable-annotation-validation: "true"
config:
strict-validate-path-type: "true" in your install values? As required to fix the latest CVEs, right? |
@opencmit2 just tested it with version 4.8.3, this is what I get in the logs:
Only when I set So I call this a bug. The annotation has a valid value, the regex compiles and is somewhat sane. I cannot feel safe setting this to false in this, multi-tenant, cluster, so I really think this validation should be fixed. edit: latest 4.10.1 version also has this problem. |
Just checked https://github.com/kubernetes/ingress-nginx/blob/main/internal/ingress/annotations/parser/validators.go#L64 It now accepts a regex like ^[\-\.\_\~a-zA-Z0-9\/:?&=]*$ For this to work none of the regexes in the file would do. The closest is the one from IsValidRegex but not quite close. For instance, it fails to have the So the working regex would be: ^[\-\.\_\~a-zA-Z0-9\/:^$\[\]\(\)\{\}*+?|&=\\<>]+$ |
cc @rikatz @tao12345666333 corner-case combo of regex in proxy-redirect-from and proxy-redirect-ro annotations |
I'm using a complex
proxy_redirect
instruction directly in nginx and it works, it changes theLocation
header so that clients are redirected to an ingress for direct connection to a specific statefulset instance. The instruction is this:This worked for years but we're moving to using ingress-nginx instead of managing nginx configs. I'm now trying to create the same thing using annotations, so tried the following:
However I get these two errors in the logs:
Now, I need guidance on why this is being refused while working perfectly in nginx and how to fix it. Tried to use a
nginx.ingress.kubernetes.io/configuration-snippet
directly but then I got:as the ingress controller always inserts a
proxy_redirect off;
instruction and that is not possible to disable.Without editing the ingress template directly, how can I implement this?
The text was updated successfully, but these errors were encountered: