我的 nginx 入口无法将包含特殊字符“[”和“]”的 URL 正确重定向到后端服务。这是我的入口配置:
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: {{ $app }}-ingress
labels:
app: {{ $app }}
chart: chart-{{ $app }}
app.kubernetes.io/managed-by: Helm
annotations:
meta.helm.sh/release-name: {{ $app }}
meta.helm.sh/release-namespace: {{ .Release.Namespace }}
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/proxy-body-size: "{{ $proxy_body_size }}"
nginx.ingress.kubernetes.io/proxy-read-timeout: "{{ $proxy_read_timeout }}"
nginx.ingress.kubernetes.io/proxy-connect-timeout: "{{ $proxy_connect_timeout }}"
nginx.ingress.kubernetes.io/proxy-send-timeout: "{{ $proxy_send_timeout }}"
nginx.ingress.kubernetes.io/proxy-buffer-size: "{{ $proxy_buffer_size }}"
nginx.ingress.kubernetes.io/rewrite-target: /$1
spec:
tls:
- hosts:
- {{ $alias }}
rules:
- host: {{ $alias }}
http:
paths:
- path: /(.*)
backend:
serviceName: {{ $app }}-service
servicePort: http-back
所有 URL 均已成功重定向,但部分 URL 包含“[”和“]”字符的情况除外。示例: https://example.com/api/v1/bookingLine/2020Z16011-00003/broadcastWave/2020Z16011-00003_20200228_20200228/content/Capture%20d%E2%80%99%C3%A9cran%202021-02-16%20103718%5B%5D.png 这些字符编码得很好,但收到的响应是 400 错误请求,当我从 png 名称中删除 [] 时,它会成功重定向。
您是否想在重写中添加对这些特殊字符的支持?
谢谢