openresty / openresty/lua-nginx-module
Can't set custom status code
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 11.8k
- Forks
- 2.1k
- Avg merge
- 6h 1m
- Merged PRs (30d)
- 6
Description
I've been having serious troubles setting the status code on returned pages. I don't know if I'm doing something wrong, there is a bug, or simply this is not supported.
I created this snippet by following some help from Google groups
rewrite_by_lua_block {
ngx.status = 206
ngx.req.set_uri("/index.html")
}
I would expect that this will forward /index.html with status code 206. Instead it returns 200.
My original snippet was like below (same behaviour)
content_by_lua_block {
ngx.status = 206
ngx.exec("/index.html")
}
I'm running the official Docker image: openresty/1.15.8.3. Following the documentation, this should work. From my digging I also found an old bug here but don't know if it's related.
In the end of the day, I simply want to return /index.html with a specific status code (depending on the status from the backend API).
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
Reproduce the behavior using the rewrite_by_lua_block and content_by_lua_block entry points shown in the issue with the openresty/1.15.8.3 image. Compare the documented ngx.status behavior with the internal redirects to /index.html and determine whether the status is expected to survive; done means the cause and supported behavior are established, with a regression test or documentation change identified.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- lua, nginx
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100