openresty / lua-nginx-module

Embed the Power of Lua into NGINX HTTP servers
https://openresty.org/
11.32k stars 2.04k forks source link

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

Open prescolt opened 5 years ago

prescolt commented 5 years ago

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
                                                    }  

.....
} `

agentzh commented 5 years ago

@prescolt Your sample configuration snippet and sample curl commands do match. Will you prepare a minimal and standalone example that we can easily run and reproduce the problem on our side without messing up with too much business details on your side?