Skip to content

URLRewrite filter does not rewrite query parameters correctly #2862

Closed
@kate-osborn

Description

@kate-osborn

Describe the bug
Query parameters are not rewritten correctly when a URLRewrite filter is configured.

To Reproduce

  1. Create the cafe app and gateway from the cafe-example

  2. Create the following HTTPRoute that configures a ReplacePrefixMatch URLRewrite filter for the PathPrefix /coffee/v1:

apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
  name: coffee
spec:
  parentRefs:
  - name: gateway
    sectionName: http
  hostnames:
  - "cafe.example.com"
  rules:
  - matches:
    - path:
        type: PathPrefix
        value: /coffee/v1
      method: GET
    filters:
      - type: URLRewrite
        urlRewrite:
          path:
            type: ReplacePrefixMatch
            replacePrefixMatch: /
    backendRefs:
    - name: coffee
      port: 80
  1. Tail the logs of the coffee Pod
  2. Send the following request curl --resolve cafe.example.com:$GW_PORT:$GW_IP http://cafe.example.com:$GW_PORT/coffee/v1/path?TEST=v2
  3. Check the access logs of the coffee Pod and you'll see that the URL was rewritten to /path%3FTEST=v2?TEST=v2

Expected behavior
The URL should be rewritten to /path?TEST=v2

Your environment

  • Version of the NGINX Gateway Fabric - v1.5
  • Version of Kubernetes - v1.31
  • Kubernetes platform (e.g. Mini-kube or GCP) - kind

Additional context
See #2858 for more details.

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingrefinedRequirements are refined and the issue is ready to be implemented.size/mediumEstimated to be completed within a week

Type

No type

Projects

Status

✅ Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions