openresty / openresty/lua-nginx-module
ngx.exec is not redirecting in the following condition
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 11.8k
- Forks
- 2.1k
- Avg merge
- 6h 1m
- Merged PRs (30d)
- 6
Description
Using openresty based nginx.
nginx version: openresty/1.19.9.1
I have a lua file in my project from there I want to call exec method for internal redirection.
My code is something like.. some rest apis call will be there as per result I want to do redirect to some location block
(In lua file)
local redirectToLogFile = function()
local redirecturl = ngx.var.scheme .. '://' .. ngx.var.host .. ":" .. ngx.var.server_port.. "/redirectlog"
return ngx.exec(redirecturl)
end
and correspondingly I have location block in nginx.conf
location ~ /redirectlog {
error_log /usr/local/openresty/nginx/logs/custom.log error;
content_by_lua_block {
ngx.log(ngx.ERR, "calling from the client " .. ngx.var.remote_addr)
}
}
What I observe is some time ngx.exec(redirecturl) is not going to /redirectlog location block when calling the api through browser. same thing is working perfectly when execute via postman.
Is it the correct way. If not how we can achieve this.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Lua file containing redirectToLogFile and the corresponding location block in nginx.conf; reproduce the behavior through both a browser and Postman while tracing ngx.exec(redirecturl). Confirm whether requests consistently reach /redirectlog and document the conditions that distinguish the two request paths.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- lua
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100