apisix
apisix copied to clipboard
bug: when URL too long,get error:{"error_msg":"404 Route Not Found"}
Current Behavior
when use apisix route request with long URL,i get this error :{"error_msg":"404 Route Not Found"}
remove one character then can access it. Add another character will get error, there is 6399 character
Is there a URL length limit ?
URL like this :
https://apisix.xxxxx.cn/ik_sl_v2_202008_weibo,ik_sl_v2_202008_weixin,ik_sl_v2_202008_news,ik_sl_v2_202008_bbs,ik_sl_v2_202008_share,ik_sl_v2_202008_video,ik_sl_v2_202008_wenda,ik_sl_v2_202008_blog,ik_sl_v2_202008_ec,ik_sl_v2_202009_weibo,ik_sl_v2_202009_weixin,ik_sl_v2_202009_news,ik_sl_v2_202009_bbs,ik_sl_v2_202009_share,ik_sl_v2_202009_video,ik_sl_v2_202009_wenda,ik_sl_v2_202009_blog,ik_sl_v2_202009_ec,ik_sl_v2_202010_weibo,ik_sl_v2_202010_weixin,ik_sl_v2_202010_news,ik_sl_v2_202010_bbs,ik_sl_v2_202010_share,ik_sl_v2_202010_video,ik_sl_v2_202010_wenda,ik_sl_v2_202010_blog,ik_sl_v2_202010_ec,ik_sl_v2_202011_weibo,ik_sl_v2_202011_weixin,ik_sl_v2_202011_news,ik_sl_v2_202011_bbs,ik_sl_v2_202011_share,ik_sl_v2_202011_video,ik_sl_v2_202011_wenda,ik_sl_v2_202011_blog,ik_sl_v2_202011_ec,ik_sl_v2_202012_weibo,ik_sl_v2_202012_weixin,ik_sl_v2_202012_news,ik_sl_v2_202012_bbs,ik_sl_v2_202012_share,ik_sl_v2_202012_video,ik_sl_v2_202012_wenda,ik_sl_v2_202012_blog,ik_sl_v2_202012_ec,ik_sl_v2_202101_weibo,ik_sl_v2_202101_weixin,ik_sl_v2_202101_news,ik_sl_v2_202101_bbs,ik_sl_v2_202101_share,ik_sl_v2_202101_video,ik_sl_v2_202101_wenda,ik_sl_v2_202101_blog,ik_sl_v2_202101_ec,ik_sl_v2_202102_weibo,ik_sl_v2_202102_weixin,ik_sl_v2_202102_news,ik_sl_v2_202102_bbs,ik_sl_v2_202102_share,ik_sl_v2_202102_video,ik_sl_v2_202102_wenda,ik_sl_v2_202102_blog,ik_sl_v2_202102_ec,ik_sl_v2_202103_weibo,ik_sl_v2_202103_weixin,ik_sl_v2_202103_news,ik_sl_v2_202103_bbs,ik_sl_v2_202103_share,ik_sl_v2_202103_video,ik_sl_v2_202103_wenda,ik_sl_v2_202103_blog,ik_sl_v2_202103_ec,ik_sl_v2_202104_weibo,ik_sl_v2_202104_weixin,ik_sl_v2_202104_news,ik_sl_v2_202104_bbs,ik_sl_v2_202104_share,ik_sl_v2_202104_video,ik_sl_v2_202104_wenda,ik_sl_v2_202104_blog,ik_sl_v2_202104_ec,ik_sl_v2_202105_weibo,ik_sl_v2_202105_weixin,ik_sl_v2_202105_news,ik_sl_v2_202105_bbs,ik_sl_v2_202105_share,ik_sl_v2_202105_video,ik_sl_v2_202105_wenda,ik_sl_v2_202105_blog,ik_sl_v2_202105_ec,ik_sl_v2_202106_weibo,ik_sl_v2_202106_weixin,ik_sl_v2_202106_news,ik_sl_v2_202106_bbs,ik_sl_v2_202106_share,ik_sl_v2_202106_video,ik_sl_v2_202106_wenda,ik_sl_v2_202106_blog,ik_sl_v2_202106_ec,ik_sl_v2_202107_weibo,ik_sl_v2_202107_weixin,ik_sl_v2_202107_news,ik_sl_v2_202107_bbs,ik_sl_v2_202107_share,ik_sl_v2_202107_video,ik_sl_v2_202107_wenda,ik_sl_v2_202107_blog,ik_sl_v2_202107_ec,ik_sl_v2_202108_weibo,ik_sl_v2_202108_weixin,ik_sl_v2_202108_news,ik_sl_v2_202108_bbs,ik_sl_v2_202108_share,ik_sl_v2_202108_video,ik_sl_v2_202108_wenda,ik_sl_v2_202108_blog,ik_sl_v2_202108_ec,ik_sl_v2_202109_weibo,ik_sl_v2_202109_weixin,ik_sl_v2_202109_news,ik_sl_v2_202109_bbs,ik_sl_v2_202109_share,ik_sl_v2_202109_video,ik_sl_v2_202109_wenda,ik_sl_v2_202109_blog,ik_sl_v2_202109_ec,ik_sl_v2_202110_weibo,ik_sl_v2_202110_weixin,ik_sl_v2_202110_news,ik_sl_v2_202110_bbs,ik_sl_v2_202110_share,ik_sl_v2_202110_video,ik_sl_v2_202110_wenda,ik_sl_v2_202110_blog,ik_sl_v2_202110_ec,ik_sl_v2_202111_weibo,ik_sl_v2_202111_weixin,ik_sl_v2_202111_news,ik_sl_v2_202111_bbs,ik_sl_v2_202111_share,ik_sl_v2_202111_video,ik_sl_v2_202111_wenda,ik_sl_v2_202111_blog,ik_sl_v2_202111_ec,ik_sl_v2_202112_weibo,ik_sl_v2_202112_weixin,ik_sl_v2_202112_news,ik_sl_v2_202112_bbs,ik_sl_v2_202112_share,ik_sl_v2_202112_video,ik_sl_v2_202112_wenda,ik_sl_v2_202112_blog,ik_sl_v2_202112_ec,ik_sl_v2_202201_weibo,ik_sl_v2_202201_weixin,ik_sl_v2_202201_news,ik_sl_v2_202201_bbs,ik_sl_v2_202201_share,ik_sl_v2_202201_video,ik_sl_v2_202201_wenda,ik_sl_v2_202201_blog,ik_sl_v2_202201_ec,ik_sl_v2_202202_weibo,ik_sl_v2_202202_weixin,ik_sl_v2_202202_news,ik_sl_v2_202202_bbs,ik_sl_v2_202202_share,ik_sl_v2_202202_video,ik_sl_v2_202202_wenda,ik_sl_v2_202202_blog,ik_sl_v2_202202_ec,ik_sl_v2_202203_weibo,ik_sl_v2_202203_weixin,ik_sl_v2_202203_news,ik_sl_v2_202203_bbs,ik_sl_v2_202203_share,ik_sl_v2_202203_video,ik_sl_v2_202203_wenda,ik_sl_v2_202203_blog,ik_sl_v2_202203_ec,ik_sl_v2_202204_weibo,ik_sl_v2_202204_weixin,ik_sl_v2_202204_news,ik_sl_v2_202204_bbs,ik_sl_v2_202204_share,ik_sl_v2_202204_video,ik_sl_v2_202204_wenda,ik_sl_v2_202204_blog,ik_sl_v2_202204_ec,ik_sl_v2_202205_weibo,ik_sl_v2_202205_weixin,ik_sl_v2_202205_news,ik_sl_v2_202205_bbs,ik_sl_v2_202205_share,ik_sl_v2_202205_video,ik_sl_v2_202205_wenda,ik_sl_v2_202205_blog,ik_sl_v2_202205_ec,ik_sl_v2_202206_weibo,ik_sl_v2_202206_weixin,ik_sl_v2_202206_news,ik_sl_v2_202206_bbs,ik_sl_v2_202206_share,ik_sl_v2_202206_video,ik_sl_v2_202206_wenda,ik_sl_v2_202206_blog,ik_sl_v2_202206_ec,ik_sl_v2_202207_weibo,ik_sl_v2_202207_weixin,ik_sl_v2_202207_news,ik_sl_v2_202207_bbs,ik_sl_v2_202207_share,ik_sl_v2_202207_video,ik_sl_v2_202207_wenda,ik_sl_v2_202207_blog,ik_sl_v2_202207_ec,ik_sl_v2_202208_weibo,ik_sl_v2_202208_weixin,ik_sl_v2_202208_news,ik_sl_v2_202208_bbs,ik_sl_v2_202208_share,ik_sl_v2_202208_video,ik_sl_v2_202208_wenda,ik_sl_v2_202208_blog,ik_sl_v2_202208_ec,ik_sl_v2_202206_video,ik_sl_v2_202206_wenda,ik_sl_v2_202206_blog,ik_sl_v2_202206_ec,ik_sl_v2_202207_weibo,ik_sl_v2_202207_weixin,ik_sl_v2_202207_news,ik_sl_v2_202207_bbs,ik_sl_v2_202207_share,ik_sl_v2_202207_video,ik_sl_v2_202207_wenda,ik_sl_v2_202207_blog,ik_sl_v2_202207_ec,ik_sl_v2_202208_weibo,ik_sl_v2_202208_weixin,ik_sl_v2_202208_news,ik_sl_v2_202208_bbs,ik_sl_v2_202208_share,ik_sl_v2_202208_video,ik_sl_v2_202208_wenda,ik_sl_v2_202208_blog,ik_sl_v2_202208_ec,ik_sl_v2_202206_video,ik_sl_v2_202206_wenda,ik_sl_v2_202206_blog,ik_sl_v2_202206_ec,ik_sl_v2_202207_weibo,ik_sl_v2_202207_weixin,ik_sl_v2_202207_news,ik_sl_v2_202207_bbs,ik_sl_v2_202207_share,ik_sl_v2_202207_video,ik_sl_v2_202207_wenda,ik_sl_v2_202207_blog,ik_sl_v2_202207_ec,ik_sl_v2_202208_weibo,ik_sl_v2_202208_weixin,ik_sl_v2_202208_news,ik_sl_v2_202208_bbs,ik_sl_v2_202208_share,ik_sl_v2_202208_video,ik_sl_v2_202208_wenda,ik_sl_v2_202208_blog,ik_sl_v2_202208_ec,ik_sl_v2_202107_video,ik_sl_v2_202107_wenda,ik_sl_v2_202107_blog,ik_sl_v2_202107_ec,ik_sl_v2_202108_weibo,ik_sl_v2_202108_weixin,ik_sl_v2_202108_news,ik_sl_v2_202108_bbs,ik_sl_v2_202108_share,ik_sl_v2_202108_video,ik_sl_v2_202108_wenda,ik_sl_v2_202108_blog,ik_sl_v2_202108_ec,ik_sl_v2_202109_weibo,ik_sl_v2_202109_weixin,ik_sl_v2_202109_news,ik_sl_v2_202109_bbs,ik_sl_v2_202109_share,ik_sl_v2_202109_video,ik_sl_v2_202109_wenda,ik_sl_v2_202109_blog,ik_sl_v2_202109_ec,ik_sl_v2_202110_weibo,ik_sl_v2_202110_weixin,ik_sl_v2_202110_news,ik_sl_v2_202110_bbs,ik_sl_v2_202110_share,ik_sl_v2_202110_video,ik_sl_v2_202110_wenda,ik_sl_v2_202110_blog,abcdefghifasfa/_search
Expected Behavior
No response
Error Logs
No response
Steps to Reproduce
Use a URL with more than 6399 characters to access apisik to reproduce
Environment
- APISIX version (run
apisix version):2.11.0 - Operating system (run
uname -a):Linux 3.10.0-957.el7.x86_64 #1 SMP 2018 x86_64 x86_64 x86_64 GNU/Linux - OpenResty / Nginx version (run
openresty -Vornginx -V):nginx version: openresty/1.19.9.1 - etcd version, if relevant (run
curl http://127.0.0.1:9090/v1/server_info):v3.5.4 - APISIX Dashboard version, if relevant:
- Plugin runner version, for issues related to plugin runners:
- LuaRocks version, for installation issues (run
luarocks --version):
@caster-Q If the url length is too large, it would response with 414, not 404. Could you show your route configuration?
@kingluo this is route conf,but I just got 404,When I reduce one URL character, I will not get this error
{ "uri": "/*", "name": "ES Proxy", "methods": [ "GET", "POST", "PUT", "DELETE", "PATCH" ], "host": "esproxy.mlamp.cn", "plugins": { "ip-restriction": { "disable": false, "whitelist": [ "127.0.0.1", "10.1.1.1/10" ] }, "proxy-rewrite": { "scheme": "https" }, "request-id": { "disable": true } }, "upstream_id": "384909973852784072", "status": 1 }
There is a URL length link.
https://github.com/apache/apisix/blob/86e9a8ea1022c34a3d5550b54a37994f174847a2/apisix/schema_def.lua#L557
I can't create such a long URL route.
{"error_msg":"invalid configuration: property \"uri\" validation failed: string too long, expected at most 4096, got 6074"}
@monkeyDluffy6017 It's not for configuration, the long uri is used in the request.
@caster-Q I could reproduce the error in my local env, and I would try to check if it's a bug later.
@kingluo thanks,Waiting for your reply
@caster-Q The route matching uses pcre_exec with jit enabled, but the long string matching exceeds the jit stack limit.
APISIX sets the stack limit to a constant. When I increase it, the route matching works.
diff --git a/apisix/init.lua b/apisix/init.lua
index 25d9d5aa..fd286c65 100644
--- a/apisix/init.lua
+++ b/apisix/init.lua
@@ -18,7 +18,7 @@ local require = require
-- set the JIT options before any code, to prevent error "changing jit stack size is not
-- allowed when some regexs have already been compiled and cached"
if require("ffi").os == "Linux" then
- require("ngx.re").opt("jit_stack_size", 200 * 1024)
+ require("ngx.re").opt("jit_stack_size", 300 * 1024)
end
require("jit.opt").start("minstitch=2", "maxtrace=4000",
@spacewander Should we set it to a bigger constant or make it configurable via config file?
I vote for configuring via config file(I even think this can be ignored and does not have to support such a long URI)
@tzssangglass I think these settings can be categorized as "advanced settings," and most of the time, we won't care about them.
I vote for configuring via config file(I even think this can be ignored and does not have to support such a long URI)
+1