Skip to content

ClientSettingsPolicy does not work on HTTPRoutes with matching conditions #2079

Closed
@kate-osborn

Description

@kate-osborn

Describe the bug
If you apply a policy to a route that has http matches with a method, params, or headers defined, the policy has no affect.

To Reproduce
Steps to reproduce the behavior:

  1. Deploy edge (118488e) version of NGF
  2. Apply the files from the advanced routing example.
  3. Create the following policy:
apiVersion: gateway.nginx.org/v1alpha1
kind: ClientSettingsPolicy
metadata:
  name: tea
  namespace: default
spec:
  targetRef:
    group: gateway.networking.k8s.io
    kind: HTTPRoute
    name: tea
  body:
    maxSize: "50"
  1. Send the following request to the tea application:
curl --resolve cafe.example.com:$GW_PORT:$GW_IP http://cafe.example.com:$GW_PORT/tea -X POST --data "this payload is greater than fifty bytes but less than seventy five"

Expected behavior
You should receive a 413 entity too large since the request body exceeds the limit

Your environment

  • Version of the NGINX Gateway Fabric - edge 118488e

Additional context
The policy is correctly included in the named location block for the tea routes, but the directives are ignored by nginx. This seems to be a limitation of named locations in nginx.

For example, this config with named locations does not enforce the client max body size:

 server {
        listen 80;

        location / {
          try_files /dev/null @named;
        }

        location @named {
          client_max_body_size 50;
          return 200 "ok two";
        }
    }

however, if you change the named location to an internal location:

   server {
        listen 80;

        location / {
          try_files /dev/null /not-named;
        }

        location /not-named {
          internal;
          client_max_body_size 50;
          return 200 "ok two";
        }
    }

it does work.

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingrefinedRequirements are refined and the issue is ready to be implemented.size/largeEstimated to be completed within two weeks

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions