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