openresty / openresty/lua-nginx-module
nginx if condition cant get a correct value from ngx.var.XXX
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 11.8k
- Forks
- 2.1k
- Avg merge
- 6h 1m
- Merged PRs (30d)
- 6
Description
Hi, I found that nginx if condition cant get a correct value from ngx.var.XXX. The ngx.var.XXX is processed by a lua script. The vhost config is
###################
location / {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
index index.html index.htm;
lua_code_cache off;
set $ab_flag "";
rewrite_by_lua_file "/usr/local/openresty/nginx/nginx_upstream_change.lua";
if ($ab_flag = "yes") {
set $ab_flag "yes";
echo "yes:" $ab_flag;
}
if ($ab_flag = "no") {
set $ab_flag "no";
echo "no:" $ab_flag;
}
echo ":" $ab_flag;
}
###################
The nginx_upstream_change.lua script will return a 'yes' or 'no' value to bind ngx.var.ab_flag variable. Use curl tool to call this vhost url, the repsonse is ": no". So i dont know why if condition is not useful. Thanks.
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 vhost configuration in the issue and the referenced nginx_upstream_change.lua script, then reproduce the response with curl. Trace when ngx.var.ab_flag is assigned and when each nginx if condition evaluates it; done means explaining why the conditions do not match the returned value or identifying the missing reproduction detail.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- lua, nginx
- Domain
- backend, devops
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100