nginx-gateway-fabric icon indicating copy to clipboard operation
nginx-gateway-fabric copied to clipboard

Restrict policies to non-duplicate routes

Open sjberman opened this issue 1 year ago • 1 comments
trafficstars

Problem: Some NGINX directives are not applied or enforced when configured in an internal location. This occurs when redirecting or rewriting a request from an external location to an internal location.

Solution: Only accept a policy if the Route it targets is the only Route that matches the hostname, port, and path combination. If other Routes overlap, the policy will be rejected.

This allows us to apply policy configuration to the external location instead of the internal locations. We would limit the policies we accept rather than limiting which Routes we accept.

This is possible because, with the policy restriction, a policy cannot be applied to a Route that shares an external location with another Route.

However, for the otel module, we still require some internal location directives to be specified, so the policy generator has been refactored to account for this.

Finally, revert named locations back to internal locations. As part of this process, we've learned that named locations do not behave as expected.

Testing: Manual verification that policies work with matching conditions, as well as Condition is set properly when overlapping routes exist in relation to a policy.

Closes #2308

Checklist

Before creating a PR, run through this checklist and mark each as complete.

  • [x] I have read the CONTRIBUTING doc
  • [ ] I have added tests that prove my fix is effective or that my feature works
  • [ ] I have checked that all unit tests pass after adding my changes
  • [ ] I have updated necessary documentation
  • [x] I have rebased my branch onto main
  • [x] I will ensure my PR is targeting the main branch and pulling from my branch from my own fork

Release notes

If this PR introduces a change that affects users and needs to be mentioned in the release notes, please add a brief note that summarizes the change.

Fix an issue that prevented ClientSettingsPolicies and ObservabilityPolicies from working when attached to an HTTPRoute where matching conditions were defined.

sjberman avatar Jul 31 '24 16:07 sjberman