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 cookie_etoken = ngx.var.cookie_etoken remote_addr = ngx.var.remote_addr 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 local etoken = ngx.md5(muacard .. remote_addr .. cookie_erandom) if (cookie_etoken ~= etoken) then return ngx.redirect("/auth?m=et&dm=muacard.vn&url=" .. request_uri) end }....} server { server_name testiq.vn www.testiq.vn; charset utf-8; ..... location / { ... rewrite_by_lua_block { cookie_erandom = ngx.var.cookie_erandom cookie_etoken = ngx.var.cookie_etoken remote_addr = ngx.var.remote_addr 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 local etoken = ngx.md5(testiq .. remote_addr .. cookie_erandom) if (cookie_etoken ~= etoken) then return ngx.redirect("/auth?m=et&dm=testiq.vn&url=" .. request_uri) end } ..... }
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