Skip to content

Add support for ReplacePrefixMatch on URLRewrite filters (Gateway Api) #1916

@jduepmeier

Description

@jduepmeier

Is your feature request related to a problem? Please describe.

Hello,

I like to use the ReplacePrefixMatch feature on URLRewrite filters of the gateway api.
Currently only ReplaceFullPath is supported.

Example Usage:

---
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
  name: test
spec:
  hostnames:
    - domain.local
  parentRefs:
    - group: gateway.networking.k8s.io
      kind: Gateway
      name: gateway
  rules:
    - backendRefs:
        - group: ""
          kind: Service
          name: backend-service
          port: 80
      matches:
        - path:
            type: PathPrefix
            value: /
    - backendRefs:
        - group: ""
          kind: Service
          name: other-service
          port: 80
      matches:
        - path:
            type: PathPrefix
            value: /other
      filters:
        - type: URLRewrite
          urlRewrite:
            hostname: other-domain.local
            path:
              type: ReplacePrefixMatch
              replacePrefixMatch: /

This sends every path under /other to the other backend service. It removes the /other path prefix from the requests.

Describe the solution you'd like

Implement ReplacePrefixMatch for HTTPRoute URLRewrite filters.

Describe alternatives you've considered

  • Strip the prefix inside the application. This is only possible if the application supports it (which is often not the case).
  • Route the request though another reverse proy which supports the rewrite. This adds additional overhead.

Additional context

Link to documention for URLRewrite: https://gateway-api.sigs.k8s.io/guides/http-redirect-rewrite/#rewrites
Api Documentation: https://gateway-api.sigs.k8s.io/reference/spec/#httppathmodifier

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions