Fixed nginx conf issue
This commit is contained in:
@@ -60,8 +60,6 @@ http {
|
||||
local res, err = red:hgetall("proxy_Host_"..domain)
|
||||
local res = red:array_to_hash(res)
|
||||
|
||||
ngx.ctx.targetInfo = res
|
||||
|
||||
if not res["ip"] then
|
||||
if connect("/var/run/proxy_lookup.socket") then
|
||||
assert(socket:send(json.encode({domain = domain})))
|
||||
@@ -76,14 +74,13 @@ http {
|
||||
end
|
||||
end
|
||||
|
||||
ngx.ctx.targetInfo = res
|
||||
|
||||
if not res["ip"] then
|
||||
ngx.log(ngx.ERR, "no host found for key ", domain)
|
||||
ngx.exit(406)
|
||||
return false
|
||||
end
|
||||
|
||||
ngx.ctx.targetInfo = res
|
||||
ngx.ctx.toAllow = true;
|
||||
|
||||
if res['wildcard_parent'] then
|
||||
|
||||
@@ -20,26 +20,33 @@ server {
|
||||
set $header_host $host;
|
||||
|
||||
access_by_lua '
|
||||
local res = ngx.ctx.targetInfo
|
||||
if not res then
|
||||
ngx.log(ngx.ERR, "no host found for key ", domain)
|
||||
ngx.exit(406)
|
||||
return false
|
||||
end
|
||||
|
||||
local host = ngx.var.host
|
||||
local uri = ngx.var.uri
|
||||
local scheme = ngx.var.scheme
|
||||
|
||||
if scheme == "http" then
|
||||
if ngx.ctx.targetInfo["forcessl"] == "true" then
|
||||
if res["forcessl"] == "true" then
|
||||
return ngx.redirect("https://"..host..uri, 301)
|
||||
end
|
||||
end
|
||||
|
||||
if ngx.ctx.targetInfo["targetssl"] == "true" then
|
||||
if res["targetssl"] == "true" then
|
||||
ngx.var.target_scheme = "https"
|
||||
end
|
||||
|
||||
if ngx.ctx.targetInfo["host-pass-though"] == "false" then
|
||||
ngx.var.header_host = ngx.ctx.targetInfo["ip"]
|
||||
if res["host-pass-though"] == "false" then
|
||||
ngx.var.header_host = res["ip"]
|
||||
end
|
||||
|
||||
ngx.var.target = ngx.ctx.targetInfo["ip"]
|
||||
ngx.var.target_port = ngx.ctx.targetInfo["targetPort"]
|
||||
ngx.var.target = res["ip"]
|
||||
ngx.var.target_port = res["targetPort"]
|
||||
';
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user