Open hmthoo opened 10 months ago
This issue is currently awaiting triage.
If Ingress contributors determines this is a relevant issue, they will accept it by applying the triage/accepted
label and provide further guidance.
The triage/accepted
label can be added by org members by writing /triage accepted
in a comment.
/remove-kind bug
/remove-kind bug
- I have not tested this and I don't fully understand the configuration snippet
- But we did harden CORS behavior and tried to harden usage of snippets https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/annotations/#configuration-snippet
- Generally, can you elaborate in complete detail, why you need to use those snippets ?
- What are you trying to achieve ?
- Have you checked the list of annotations and are you sure you can not achieve what you want, with annotations ?
- You are trying to set a variable and then use that variable to set a backend. Why ?
Specific Cookie Routing: Without focusing on nginx.ingress.kubernetes.io/configuration-snippet and only considering the desire to route requests with a specific cookie (uid is test) to a specified service (svc), you can achieve this by configuring the Ingress to check the cookie and route accordingly.
Objective:
The goal is to have the response header access-control-allow-headers
reflect the values set in nginx.ingress.kubernetes.io/cors-allow-headers
.
Current Situation:
Only configuring nginx.ingress.kubernetes.io/cors-allow-headers
achieves the second objective.
However, when nginx.ingress.kubernetes.io/configuration-snippet
is configured, the response header no longer reflects the values set in nginx.ingress.kubernetes.io/cors-allow-headers
.
The closest I have come to Cookie based routing is while configuring affinity https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/annotations/#session-affinity
I was under the impression that routing with ingress was only possible with either the host
or the path
. Do you already know for sure that you can configure cookie based routing or are you experimenting
I have zero/nada/zilch thoughts that loss of headers after using snippet. Vague guess is that someone was talking about sub-locations in nginx.conf causing loss of headers in the use-case of auth related annotations
- The closest I have come to Cookie based routing is while configuring affinity https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/annotations/#session-affinity
- I was under the impression that routing with ingress was only possible with either the
host
or thepath
. Do you already know for sure that you can configure cookie based routing or are you experimenting- I have zero/nada/zilch thoughts that loss of headers after using snippet. Vague guess is that someone was talking about sub-locations in nginx.conf causing loss of headers in the use-case of auth related annotations
Don't focus on cookies!
Yes, I'm just curious why setting the snippet causes headers to be lost, whereas it was normal in previous versions of ingress.
Can you add proof that exactly same configuration snippet did not cause loss of headers in a previous version of the controller ? With as much details as possible ? That will make it easier for a developer to review the PRs between the 2 versions of the controller
Did you set the allow-snippet-annotations
to true? We changed the default to false in 1.9.X
Did you set the
allow-snippet-annotations
to true? We changed the default to false in 1.9.X
I have set allow-snippet-annotations: "true"
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 #ingress-nginx-dev
on Kubernetes Slack.
NGINX Ingress controller: v1.9.4 k8s Verson: v1.27.3
My operation is as follows
test success
curl test success when i not adding the
nginx.ingress.kubernetes.io/configuration-snippet
. response headeraccess-control-allow-headers
is ingressnginx.ingress.kubernetes.io/cors-allow-headers
ingress config
test failed
curl test failed , response header
access-control-allow-headers
is not ingressnginx.ingress.kubernetes.io/cors-allow-headers
ingress config add
nginx.ingress.kubernetes.io/configuration-snippet
:This problem was not encountered in my previous ingress version. In this version, in addition to using
more_set_headers
to set the cors header in eachnginx.ingress.kubernetes.io/configuration-snippet
.nginx.ingress.kubernetes.io/cors-allow-headers
is set, it doesn’t feel like a good idea to set it again for eachnginx.ingress.kubernetes.io/configuration-snippet
.Are there any other good ways?