Skip to content

Instantly share code, notes, and snippets.

@u8sand
Last active January 30, 2023 19:32
Show Gist options
  • Save u8sand/a49b96bf5494fc010e28dd3411f92b07 to your computer and use it in GitHub Desktop.
Save u8sand/a49b96bf5494fc010e28dd3411f92b07 to your computer and use it in GitHub Desktop.
This patches the ingress-nginx controller to use case sensitive path prefix matching

case-sensitive-ingress-nginx

This patches the ingress-nginx controller to use case sensitive path prefix matching.

My issue in the repo was ignored kubernetes/ingress-nginx#7010

FROM registry.k8s.io/ingress-nginx/controller:v1.5.1@sha256:4ba73c697770664c1e00e9f968de14e08f606ff961c76e5d7033a4a9c593c629
ADD nginx.tmpl.patch ./template/nginx.tmpl.patch
RUN patch -p0 -i ./template/nginx.tmpl.patch
--- template/nginx.tmpl.orig 2023-01-26 19:02:15.878440041 -0500
+++ template/nginx.tmpl 2023-01-26 19:05:44.424283923 -0500
@@ -1183,7 +1183,12 @@
{{ end }}
{{ end }}
+ # replace case insensitive with case sensitive
+ {{ if hasPrefix $path "~*" }}
+ location ~ {{ slice $path 2 }} {
+ {{ else }}
location {{ $path }} {
+ {{ end }}
{{ $ing := (getIngressInformation $location.Ingress $server.Hostname $location.IngressPath) }}
set $namespace {{ $ing.Namespace | quote}};
set $ingress_name {{ $ing.Rule | quote }};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment