Description
What happened:
An ingress containing an anchor within the app-root
redirect annotation fails validation:
nginx.ingress.kubernetes.io/app-root: /_dashboards/app/home#/
What you expected to happen:
After updating Ingress-Nginx to 1.12.0
release, we encountered the following issue with app-root
annotation. The "issue" itself was not introduced within 1.12.0
but was realized because of the new default enablement of --enable-annotation-validation
(see flags.go).
So far so good, we are wondering why this specific annotation validation should fail in our case:
W0211 15:42:00.195018 7 validators.go:237] validation error on ingress my-namespace/my-ingress: annotation app-root contains invalid value /_dashboards/app/home#/
The Ingress itself is related to an OpenSearch installation which uses anchor/fragments for many aspects of client-side logic and deeplinking.
We totally aggree that this is an edge case and in our case we can solve the problem by adjusting the value to /_dashboards/app/home
, since the fragment/anchor is appended properly on client side again.
But we are wondering if the validation itself is spec conform about URL/URI pattern.
-
According to RFC 3986 Syntax the fragments part of the URI should be valid.
-
According to RFC 9110 about HTTP semantics a fragment seems to be a valid part of a HTTP 3xx Response.
-
Also RFC 9110 links to RFC 3986 for Relative reference URI format
So in our opinion, the fragment/anchor part of the redirect seems to be valid and might be worth to add to valid options?
Relevant lines of code:
Annotation Validation of URLs via regex:
- https://github.com/kubernetes/ingress-nginx/blob/release-1.12/internal/ingress/annotations/parser/validators.go#L47
- https://github.com/kubernetes/ingress-nginx/blob/release-1.12/internal/ingress/annotations/parser/validators.go#L64
Additional, specific validation to app-route
annotation via net/url
lib:
NGINX Ingress controller version (exec into the pod and run /nginx-ingress-controller --version
):
-------------------------------------------------------------------------------
NGINX Ingress controller
Release: v1.12.0
Build: ba73b2c24d355f1cdcf4b31ef7c5574059f12118
Repository: https://github.com/kubernetes/ingress-nginx
nginx version: nginx/1.25.5
-------------------------------------------------------------------------------
Kubernetes version (use kubectl version
): Server Version: v1.30.8-eks-2d5f260
(not related to the issue)
Environment:
Since this issue is related to annotation validation within the nginx code (see above), it is not related to any infrastructure, kernel or hardware versions at all.
How to reproduce this issue:
Ingress which triggers this issue:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: example-app-root-anchor
annotations:
nginx.ingress.kubernetes.io/app-root: /foo#/
spec:
ingressClassName: nginx
rules:
- host: <foo.example.com>
http:
paths:
- backend:
service:
name: foo
port:
number: 443
path: /
pathType: Prefix
Ingress-Nginx config consists of at least Medium
risk level according to the docs.
annotations-risk-level: Critical
Anything else we need to know:
Metadata
Metadata
Assignees
Labels
Type
Projects
Status