lua-nginx-module
lua-nginx-module copied to clipboard
subrequest cycle problem
nginx version: openresty/1.19.9.1 ngx_lua-0.10.20
-- my nginx.conf worker_processes 1; user root; pcre_jit on;
events { worker_connections 1024; }
http { lua_package_path '$prefix/?.lua;$prefix/resty_modules/lualib/?.lua;;'; lua_code_cache off; default_type text/plain; keepalive_timeout 65;
server {
listen 8080;
location / {
content_by_lua_file lua/not_found.lua;
}
location = /main {
content_by_lua_file lua/main.lua;
}
location = /sub {
content_by_lua_file lua/sub.lua;
}
}
}
-- main.lua local res = ngx.location.capture("/sub") ngx.say(res.body) ngx.say("main")
-- sub.lua ngx.say("sub")
-- question with lua_code_cache off; when first issue curl /sub then curl /main just got subrequest cycle error as follow
stack traceback: coroutine 0: [C]: in function 'capture' /root/study/test/lua/main.lua:1: in main chunk, client: 127.0.0.1, server: , request: "GET /main HTTP/1.1", subrequest: "/sub", host: "localhost:8080" 2022/04/19 01:21:07 [error] 25279#25279: *10 lua subrequests cycle while processing "/sub", client: 127.0.0.1, server: , request: "GET /main HTTP/1.1", subrequest: "/sub", host: "localhost:8080" 2022/04/19 01:21:07 [error] 25279#25279: *10 lua entry thread aborted: runtime error: /root/study/test/lua/main.lua:1: failed to issue subrequest: -1 stack traceback: coroutine 0: [C]: in function 'capture' /root/study/test/lua/main.lua:1: in main chunk, client: 127.0.0.1, server: , request: "GET /main HTTP/1.1", subrequest: "/sub", host: "localhost:8080"
and curl /main just print 51 line "mian" without any "sub" is this intended ? and i couldn't figure it out
-- sub.lua
local res = ngx.location.capture("/sub")
ngx.say(res.body)
ngx.say("main")
It it a typo? ngx.say("main") should be ngx.say("sub")
-- sub.lua local res = ngx.location.capture("/sub") ngx.say(res.body) ngx.say("main")
It it a typo? ngx.say("main") should be ngx.say("sub")
sorry for paste error. sub.lua just one line code as follow, -- sub.lua ngx.say("sub")
Do you still have doubts? you also remove the ngx.capture from sub.lua, is that expected?
-- sub.lua
ngx.say("sub")
Do you still have doubts? you also remove the ngx.capture from sub.lua, is that expected?
-- sub.lua ngx.say("sub")
yes it is just that simple. and when lua_code_cache off; it do produce subrquests cycle problem.