ingress-nginx
ingress-nginx copied to clipboard
Rewrite Rules Not Working in NGINX Ingress Controller v1.9.0+
Description After upgrading from NGINX Ingress Controller v1.8.5 to v1.9.0+, the configuration-snippet no longer applies rewrite rules or sub_filter modifications. This behavior worked correctly in v1.8.5 and earlier versions, but after v1.9.0, the snippet is ignored
Ingress File:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
annotations:
meta.helm.sh/release-name: app-test
meta.helm.sh/release-namespace: test
nginx.ingress.kubernetes.io/configuration-snippet: |
sub_filter "/openapi.json'"/backend/openapi.json';
sub_filter_once off;
nginx.ingress.kubernetes.io/rewrite-target: /$2
nginx.ingress.kubernetes.io/health-check-fails: "2"
nginx.ingress.kubernetes.io/health-check-interval: "10"
nginx.ingress.kubernetes.io/health-check-path: /api/v1/health
nginx.ingress.kubernetes.io/health-check-retries: "3"
nginx.ingress.kubernetes.io/health-check-succeeds: "2"
nginx.ingress.kubernetes.io/health-check-timeout: "5"
nginx.ingress.kubernetes.io/proxy-body-size: 500m
nginx.ingress.kubernetes.io/proxy-buffering: "off"
name: ingress-test
namespace: test
spec:
ingressClassName: nginx
rules:
- host: test.demo.com
http:
paths:
- backend:
service:
name: <service-name>
port:
number: 8000
path: /backend(/|$)(.*)
pathType: ImplementationSpecific
tls:
- hosts:
- test.demo.com
secretName: <secret-name>
Actual Behaviour We want the endpoints to work as below: https://test.demo.com/backend/docs --> swagger ui page (this is not working as the next call goes to /openapi.json where it is dropping "/backend" from the call and the call is not able to complete) https://test.demo.com/backend/api/v1/health --> health check page working fine
Expected Behaviour: The configuration-snippet with sub_filter should correctly modify the response body in NGINX, as it did in versions 1.8.5 and earlier
Troubleshooting Done
Verified that the snippet is applied in the generated nginx.conf file (kubectl exec -it
Request for Assistance Can the NGINX Ingress team confirm if this is an intentional change or a regression bug? If intentional, what is the new recommended way to apply sub_filter transformations in v1.9.0+?