request help: url contains Chinese, will decode utf8 encoded url into hexadecimal format of \x
Current Behavior
raw url: https://xxx.com/a/中文.html url will encode this: https://xxx.com/a/%E4%B8%AD%E6%96%87.html fact in apisix: https://xxx.com/a/\xE4\xB8\xAD\xE6\x96\x87.html
Expected Behavior
No response
Error Logs
No response
Steps to Reproduce
raw url: https://xxx.com/a/中文.html url will encode this: https://xxx.com/a/%E4%B8%AD%E6%96%87.html fact in apisix: https://xxx.com/a/\xE4\xB8\xAD\xE6\x96\x87.html
Environment
- APISIX version (run
apisix version):2.15 - Operating system (run
uname -a): - OpenResty / Nginx version (run
openresty -Vornginx -V): - etcd version, if relevant (run
curl http://127.0.0.1:9090/v1/server_info): - APISIX Dashboard version, if relevant:
- Plugin runner version, for issues related to plugin runners:
- LuaRocks version, for installation issues (run
luarocks --version):
curl "http://127.0.0.1:9080/apisix/admin/routes/1" -H "X-API-KEY: edd1c9f034335f136f87ad84b625c8f1" -X PUT -d '
{
"methods": ["GET"],
"host": "example.com",
"uri": "/中文/*",
"upstream": {
"type": "roundrobin",
"nodes": {
"httpbin.org:80": 1
}
}
}'
curl -i -X GET "http://127.0.0.1:9080/中文/foo?arg=10" -H "Host: [example.com](http://example.com/)
curl -i -X GET "http://127.0.0.1:9080/%E4%B8%AD%E6%96%87/foo?arg=10" -H "Host: [example.com](http://example.com/)"
I test with the above test case, and both successfully match the route. Could you tell me how i reproduce the problem?
curl "http://127.0.0.1:9080/apisix/admin/routes/1" -H "X-API-KEY: edd1c9f034335f136f87ad84b625c8f1" -X PUT -d ' { "methods": ["GET"], "host": "example.com", "uri": "/中文/*", "upstream": { "type": "roundrobin", "nodes": { "httpbin.org:80": 1 } } }' curl -i -X GET "http://127.0.0.1:9080/中文/foo?arg=10" -H "Host: [example.com](http://example.com/) curl -i -X GET "http://127.0.0.1:9080/%E4%B8%AD%E6%96%87/foo?arg=10" -H "Host: [example.com](http://example.com/)"I test with the above test case, and both successfully match the route. Could you tell me how i reproduce the problem?
Em... Match route is ok. I want to say , when url contains Chinese ,upstream will recevie hex ,like this \xE4\xB8\xAD\xE6\x96\x87
https://github.com/apache/apisix/pull/7401 Does this feature will help?
#7401 Does this feature will help?
I set proxy-rewrite.use_real_request_uri_unsafe=true in global by Apisix dashboard, not work
request APISIX
curl -i -X GET "http://127.0.0.1:9080/%25E4%25B8%25AD%25E6%2596%2587/foo?arg=10"
HTTP/1.1 200 OK
Content-Type: application/octet-stream
Transfer-Encoding: chunked
Connection: keep-alive
Date: Fri, 09 Sep 2022 08:37:46 GMT
Server: APISIX/2.15.0
upstream nginx log:
==> logs/access.log <==
127.0.0.1 - - [09/Sep/2022:16:37:46 +0800] "GET /%25E4%25B8%25AD%25E6%2596%2587/foo?arg=10 HTTP/1.1" 200 35 "-" "curl/7.58.0"
APISIX will not change your URL, it just forward your URL if you don't use any plugin.
So where is the problem?
Many web server, like nginx, it will decode the url-encoded URL before match the route.
So I guess you could encoded your URL twice like the example above.
@biubiue any updates? If not, please close this issue. Thanks.
Due to lack of the reporter's response this issue has been labeled with "no response". It will be close in 3 days if no further activity occurs. If this issue is still relevant, please simply write any comment. Even if closed, you can still revive the issue at any time or discuss it on the [email protected] list. Thank you for your contributions.
This issue has been closed due to lack of activity. If you think that is incorrect, or the issue requires additional review, you can revive the issue at any time.