Skip to content

bug: proxy-rewrite discard the query string when use_real_request_uri_unsafe is true #12623

@keilon

Description

@keilon

Current Behavior

Using the proxy-rewrite plugin to modify the request uri, if use_real_request_uri_unsafe is set to true, the queryString of original request will be discarded. And returned to normal when use_real_request_uri_unsafe is set to false(default),

Expected Behavior

Whether or not use_real_request_uri_unsafe is enabled, the queryString should not be discarded.

Error Logs

No response

Steps to Reproduce

  1. Add route with proxy-rewrite plugin:
curl -XPUT -H "x-api-key:${ADMIN_KEY}" http://localhost:9180/admin/apisix/routes \
-d '{
    "id": "httpbin-get",
    "methods": ["GET"],
    "uri": "/fakeget",
    "plugins": {
      "proxy-rewrite": {
        "uri": "/get",
        "use_real_request_uri_unsafe": true
      }
    },
    "upstream": {
      "type": "roundrobin",
      "pass_host": "node",
      "nodes": {
        "httpbin.org:80": 1
      }
    }
  }'
  1. Send httpbin GET request with query param curl -XGET "localhost:9080/fakeget?foo=bar"
Image
  1. Update proxy-rewrite plugin setting:
curl -XPUT -H "x-api-key:${ADMIN_KEY}" http://localhost:9180/admin/apisix/routes \
-d '{
    "id": "httpbin-get",
    "methods": ["GET"],
    "uri": "/fakeget",
    "plugins": {
      "proxy-rewrite": {
        "uri": "/get",
        "use_real_request_uri_unsafe": false
      }
    },
    "upstream": {
      "type": "roundrobin",
      "pass_host": "node",
      "nodes": {
        "httpbin.org:80": 1
      }
    }
  }'
  1. Send the same request curl -XGET "localhost:9080/fakeget?foo=bar"
Image

Environment

  • APISIX version (run apisix version): 3.13.0
  • Operating system (run uname -a): Debian GNU/Linux 11
  • OpenResty / Nginx version (run openresty -V or nginx -V): openresty/1.27.1.2

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

Status

🏗 In progress

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions