help request: Why does ngx.req.set_uri_args fail after proxy rewrite is enabled? #6997
Unanswered
kingmouse-yx
asked this question in
Q&A
Replies: 1 comment
-
Because the variable Line 705 in 2800a06
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Description
I have a requirement now. I need to parse some data in the request body, splice it behind the URL, and then forward it to the upstream.
Original request:
url:
http://192.168.2.11:9080/userinfo
body:
final request:
http://192.168.2.11:9080/userinfo?userId=12345&type=01
This seems to be a very simple requirement, so I get the message in the rewrite phase and use gx.req.set_uri_args.
Part code:
This test is completely OK. It can really meet this requirement. But I found that if the proxy rewrite is enabled (modify the path or modify the request method, etc.), the request to the downstream URL is an error. The data in the body is not spliced behind the url. This can be seen through the log.
I checked the implementation logic of the proxy rewrite. I found that in the proxy rewrite, it is by modifying ctx.var.upstream_ uri to modify the url.
So I made a judgment in my code, as follows:
After this processing, this requirement can be realized whether the proxy rewrite is enabled or not.
But I don't quite understand why apisix handles it in this way. I think ngx.req.set_uri_args is more convenient
Environment
apisix version
): 2.13.0-alpineuname -a
): Darwin kingmouse.local 21.4.0 Darwin Kernel Version 21.4.0: Mon Feb 21 20:36:53 PST 2022; root:xnu-8020.101.4~2/RELEASE_ARM64_T8101 arm64openresty -V
ornginx -V
): openresty/1.19.3.1curl http://127.0.0.1:9090/v1/server_info
): 3.4.0luarocks --version
):Beta Was this translation helpful? Give feedback.
All reactions