в оригинале так:
set $upstream "";
rewrite_by_lua_block {
local routes = ngx.shared.routes
local route = routes:get(ngx.var.http_host)
if route == nil then
local redis = require "redis"
local client = redis:new()
local ok, error = client:connect("
127.0.0.1", 6379)
if ok then
route = client:get(ngx.var.http_host)
else
ngx.log(ngx.ERR, "Redis connection failure")
end
end
if route ~= nil and route ~= ngx.null then
ngx.var.upstream = route
routes:set(ngx.var.http_host, route)
if route == "maintenance" then
ngx.req.set_uri("/errorpage/" .. ngx.var.errorpage_template .. "/maintenance", true)
end
else
ngx.exit(ngx.HTTP_NOT_FOUND)
end
}
proxy_pass http://$upstream;