openresty / openresty/lua-nginx-module

openresty/1.13.6.2, problem with lua core block isolation per nginx server configuration

Open
#1,429 1 comment 0 reactions 0 assignees View on GitHub

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 have problem after upgrade to openresty/1.13.6.2, ubuntu 16.04. openresty was build by source.
My request go to server A have been process by lua block on other Server config block of nginx, let me show the detail with curl and sample config. I do not meet problem on the old version.

curl -I https://testiq.vn/
HTTP/1.1 302 Moved Temporarily
Date: Sat, 24 Nov 2018 18:20:08 GMT
Content-Type: text/html
Content-Length: 160
Connection: keep-alive
Location: /auth?m=er&dm=muacard.vn&url=/
Server: HCM
Cache-Control: public

curl -I https://muacard.vn/
HTTP/1.1 302 Moved Temporarily
Date: Sat, 24 Nov 2018 18:20:08 GMT
Content-Type: text/html
Content-Length: 160
Connection: keep-alive
Location: /auth?m=er&dm=testiq.vn&url=/
Server: HCM
Cache-Control: public

==> As you see, two CURL go wrong rewrite_by_lua_block , the problem affect access_by_lua_block and variable too. Some time it go true, and some time it go wrong, base on traffic of earch sites. All sites have less traffic will use LUA block of sites have most traffic.

nginx version: openresty/1.13.6.2 (build custom build v1.2)
built by gcc 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.10)
built with OpenSSL 1.1.1 11 Sep 2018
TLS SNI support enabled
configure arguments: --prefix=/opt/build/openresty/nginx --with-cc-opt=-O2 --add-module=../ngx_devel_kit-0.3.0 --add-module=../echo-nginx-module-0.61 --add-module=../xss-nginx-module-0.06 --add-module=../ngx_coolkit-0.2rc3 --add-module=../set-misc-nginx-module-0.32 --add-module=../form-input-nginx-module-0.12 --add-module=../encrypted-session-nginx-module-0.08 --add-module=../srcache-nginx-module-0.31 --add-module=../ngx_lua-0.10.13 --add-module=../ngx_lua_upstream-0.07 --add-module=../headers-more-nginx-module-0.33 --add-module=../array-var-nginx-module-0.05 --add-module=../memc-nginx-module-0.19 --add-module=../redis2-nginx-module-0.15 --add-module=../redis-nginx-module-0.3.7 --add-module=../rds-json-nginx-module-0.15 --add-module=../rds-csv-nginx-module-0.09 --add-module=../ngx_stream_lua-0.0.5 --with-ld-opt=-Wl,-rpath,/opt/build/openresty/luajit/lib --user=nginx --group=nginx --with-openssl=/opt/build/scripts/build_src/include/openssl-1.1.1 --build='build custom build v1.2' --with-http_realip_module --with-file-aio --with-http_v2_module --with-ipv6 --with-pcre-jit --with-pcre=/opt/build/scripts/build_src/include/pcre-8.42 --with-http_ssl_module --with-stream --with-stream_ssl_module --with-http_geoip_module --with-pcre --with-http_stub_status_module --add-module=/opt/build/scripts/build_src/include/nginx-module-vts --add-dynamic-module=/opt/build/scripts/build_src/include/ModSecurity-nginx --add-dynamic-module=/opt/build/scripts/build_src/include/traffic-accounting-nginx-module --add-module=/opt/build/scripts/build_src/include/ngx_cache_purge --add-module=/opt/build/scripts/build_src/download/incubator-pagespeed-ngx-1.13.35.2-stable --with-stream --with-stream_ssl_module

`server {

    server_name muacard.vn www.muacard.vn;
    charset utf-8;
    set $native_ssl 0;
    .....
		location / {
           ...
				   rewrite_by_lua_block {
                            cookie_erandom  = ngx.var.cookie_erandom                                
                            request_uri     = ngx.var.request_uri                             
                            domain          ="muacard.vn"
                            if (cookie_erandom == nil) then
                                    return ngx.redirect("/auth?m=er&dm=muacard.vn&url=" .. request_uri)
                            end
                                                    }

....
}

server {

    server_name testiq.vn www.testiq.vn;
    charset utf-8;
    .....
		location / {
           ...
				   rewrite_by_lua_block {
                            cookie_etoken   = ngx.var.cookie_etoken
                            request_uri     = ngx.var.request_uri                             
                            domain          ="testiq.vn"
                            if (cookie_erandom == nil) then
                                    return ngx.redirect("/auth?m=er&dm=testiq.vn&url=" .. request_uri)
                            end
                                                    }  

.....
} `

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the two curl requests against the shown nginx server blocks and compare the rewrite_by_lua_block behavior under openresty/1.13.6.2. Inspect how Lua state and variables are scoped across server configurations, then verify that each host redirects with its own domain and request data without cross-request interference.

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.