In header_filter_by_lua_file I'm setting all the headers for downloading a file.
location /download {
access_by_lua_file "/etc/nginx/luaFiles/auth.lua";
header_filter_by_lua_file "/etc/nginx/luaFiles/header.lua";
alias "/uploads/";
}
access_by_lua_file:
auth.lua
In this file i'm calling an API, if status code return by api is not equal to 200 then I should terminate the connection without allowing the file to download. Here I'm using ngx.exit with the status code to terminate the connection. But
connection is not terminated it's still going
in to the header_filter_by_lua_file.
if res then
if res.status==200 then
ngx.status=res.status
return
end
if res.status~=200 then
ngx.status=res.status
ngx.say("error code :",res.status)
return ngx.exit(res.status)
end
else
ngx.status=500
ngx.say("failed to request: ",err)
ngx.exit(500)
end
please help me to terminate the connection without going into header_filter_by_lua_file.