Closed iusergii closed 1 year 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 /kind feature
/remove-kind bug /kind feature
@longwuyuan: Those labels are not set on the issue: kind/bug
Hi @iusergii Could you please provide more info, like your ingress spec? If the URL is not merged and not matched, the response should be 404 Not Found
. 500
response code means Internal Server Error
. And no errors when using https://bar.com/foo/zhs/api
?
I need to cut path prefix and I cannot use rewrite-target as it fails in case of special character there.
Applications built on top of Spring Boot and it requires X-Forwarded-Prefix headers. So my ingress rules looks like this:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
annotations:
nginx.ingress.kubernetes.io/backend-protocol: HTTPS
nginx.ingress.kubernetes.io/configuration-snippet: |
more_clear_input_headers ;
proxy_set_header X-Forwarded-Prefix /foo/zhs/api;
if ($request_uri ~ "^/foo/zhs/api(.*)") {
proxy_pass https://upstream_balancer$1;
break;
}
name: foo
spec:
ingressClassName: nginx
rules:
- host: '*.com'
http:
paths:
- backend:
service:
name: foo
port:
name: https
path: /foo/zhs/api
pathType: Prefix
URI without double slash https://bar.com/foo/zhs/api
works.
@iusergii I tested it with your spec on my local machine. $request_uri
is not changed even after merging slashes. So your condition $request_uri ~ "^/foo/zhs/api(.*)"
is not matched when using https://bar.com//foo/zhs/api
, then your requests are routed to foo service, not https://upstream_balancer$1
.
A feasible solution is to update your regex: $request_uri ~ "^(/+)foo(/+)zhs(/+)api(.*)"
(but it needs your load balancer to be able to recognize and accept the requests with multiple slashes in a URI)
@z1cheng thank you for clarification. This seems really an issue with workaround. Closing.
What happened: I have use case when application makes request https://bar.com//foo/zhs/api and as result I have 500.
What you expected to happen:
I was under immersion that merge_slashes is enabled by default and should merge it.
NGINX Ingress controller version:
1.3.1
Kubernetes version:1.21.14