How to restrict the URL length in nginx ingress?

132 Views Asked by At

I have an application is accessible from url: hw.internal.com/api/apple.

Now I want to restrict the length of the url that can be fired to 26 characters. That is if i try to call hw.internal.com/api/watermelons it should give 414 error as the url length exceeded 26 characters.

I found that I could use the following code lines in Ingress by which I could restrict the url length to 26 characters.

nginx.ingress.kubernetes.io/server-snippet: |
      if ($request_uri ~* "^/.{26,}") {
        return 414;
      }

However I want to know if there are there any annotations available for ingress that would help me achieve this.

0

There are 0 best solutions below