0

My nginx ingress dont redirect correctly urls having the special characters "[" and "]" to the backend service. There is my ingress config:

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

All Urls are redirected to back successfully, except some urls witch have "[" and "]" characters. Example: 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 These characters are well encoded but the received response is 400 Bad request When I remove [] from the name of png it redirect successfully.

Have you idea to add support of these special characters in rewrite?

Thanks

  • Hi Ammar, welcome to S.F. I don't know this to be your problem, but a `path` of `/(.+)` with a `rewrite-target` of `/$1` in nonsense, as that's the URI it would have used without invoking the rewrite mechanism. More on topic, have you checked that the 400 isn't coming from your upstream service? – mdaniel Feb 17 '21 at 03:10
  • Hi mdaniel, with this rewrite configuration the front invokes the back without any problem except for the urls containing the characters "[" and "]" – Ammar Rami Feb 17 '21 at 10:24
  • I dont have any trace in the upostream logs following the sending of the request. So, I think that the problem is between the frontend and the backend. – Ammar Rami Feb 17 '21 at 10:31
  • It seems to be a bug. Did you take a look: https://github.com/kubernetes/ingress-nginx/issues/5576 – Malgorzata Mar 03 '21 at 14:45

0 Answers0