-- opm get ledgetech/lua-resty-http -- https://unraid.amass.fun/ -- http://127.0.0.1:3001/wt/login?redirect=https%3A%2F%2Famass.fun%0A local wtauth_cookie = ngx.var.cookie_wtauth local server = "" if ngx.var.server_port == "80" or ngx.var.server_port == "443" then server = ngx.var.host else server = ngx.var.host .. ":" .. ngx.var.server_port end local target_url = ngx.var.scheme .. "://" .. server .. ngx.var.request_uri if not wtauth_cookie then return ngx.redirect('https://amass.fun/wt/login?redirect=' .. ngx.escape_uri(target_url)) end local http = require "resty.http" local httpc = http.new() local res, err = httpc:request_uri("http://127.0.0.1:8082/api/v1/auth/verify", { method = "GET", headers = { ["Content-Type"] = "application/json", ["Cookie"] = "wtauth=" .. wtauth_cookie } }) if not res then ngx.log(ngx.ERR, "failed to request: ", err) return ngx.exit(500) end if res.status ~= 200 then return ngx.redirect('https://amass.fun/wt/login?redirect=' .. ngx.escape_uri(target_url)) end