fix bug with balancer.lua configuration
This commit is contained in:
parent
9fe500319c
commit
5cc116fa10
2 changed files with 20 additions and 3 deletions
|
@ -884,8 +884,8 @@ stream {
|
||||||
rewrite_by_lua_block {
|
rewrite_by_lua_block {
|
||||||
balancer.rewrite()
|
balancer.rewrite()
|
||||||
}
|
}
|
||||||
{{ if shouldConfigureLuaRestyWAF $all.Cfg.DisableLuaRestyWAF $location.LuaRestyWAF.Mode }}
|
|
||||||
access_by_lua_block {
|
access_by_lua_block {
|
||||||
|
{{ if shouldConfigureLuaRestyWAF $all.Cfg.DisableLuaRestyWAF $location.LuaRestyWAF.Mode }}
|
||||||
local lua_resty_waf = require("resty.waf")
|
local lua_resty_waf = require("resty.waf")
|
||||||
local waf = lua_resty_waf:new()
|
local waf = lua_resty_waf:new()
|
||||||
|
|
||||||
|
@ -912,16 +912,21 @@ stream {
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
waf:exec()
|
waf:exec()
|
||||||
|
{{ end }}
|
||||||
}
|
}
|
||||||
header_filter_by_lua_block {
|
header_filter_by_lua_block {
|
||||||
|
{{ if shouldConfigureLuaRestyWAF $all.Cfg.DisableLuaRestyWAF $location.LuaRestyWAF.Mode }}
|
||||||
local lua_resty_waf = require "resty.waf"
|
local lua_resty_waf = require "resty.waf"
|
||||||
local waf = lua_resty_waf:new()
|
local waf = lua_resty_waf:new()
|
||||||
waf:exec()
|
waf:exec()
|
||||||
|
{{ end }}
|
||||||
}
|
}
|
||||||
body_filter_by_lua_block {
|
body_filter_by_lua_block {
|
||||||
|
{{ if shouldConfigureLuaRestyWAF $all.Cfg.DisableLuaRestyWAF $location.LuaRestyWAF.Mode }}
|
||||||
local lua_resty_waf = require "resty.waf"
|
local lua_resty_waf = require "resty.waf"
|
||||||
local waf = lua_resty_waf:new()
|
local waf = lua_resty_waf:new()
|
||||||
waf:exec()
|
waf:exec()
|
||||||
|
{{ end }}
|
||||||
}
|
}
|
||||||
|
|
||||||
log_by_lua_block {
|
log_by_lua_block {
|
||||||
|
@ -933,7 +938,6 @@ stream {
|
||||||
balancer.log()
|
balancer.log()
|
||||||
monitor.call()
|
monitor.call()
|
||||||
}
|
}
|
||||||
{{ end }}
|
|
||||||
|
|
||||||
{{ if (and (not (empty $server.SSLCert.PemFileName)) $all.Cfg.HSTS) }}
|
{{ if (and (not (empty $server.SSLCert.PemFileName)) $all.Cfg.HSTS) }}
|
||||||
if ($scheme = https) {
|
if ($scheme = https) {
|
||||||
|
|
|
@ -53,7 +53,20 @@ var _ = framework.IngressNginxDescribe("Dynamic Configuration", func() {
|
||||||
ensureIngress(f, "foo.com")
|
ensureIngress(f, "foo.com")
|
||||||
})
|
})
|
||||||
|
|
||||||
It("should set nameservers for Lua", func() {
|
It("configures balancer Lua middleware correctly", func() {
|
||||||
|
err := f.WaitForNginxConfiguration(func(cfg string) bool {
|
||||||
|
return strings.Contains(cfg, "balancer.init_worker()") && strings.Contains(cfg, "balancer.balance()")
|
||||||
|
})
|
||||||
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
|
||||||
|
host := "foo.com"
|
||||||
|
err = f.WaitForNginxServer(host, func(server string) bool {
|
||||||
|
return strings.Contains(server, "balancer.rewrite()") && strings.Contains(server, "balancer.log()")
|
||||||
|
})
|
||||||
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
})
|
||||||
|
|
||||||
|
It("sets nameservers for Lua", func() {
|
||||||
err := f.WaitForNginxConfiguration(func(cfg string) bool {
|
err := f.WaitForNginxConfiguration(func(cfg string) bool {
|
||||||
r := regexp.MustCompile(`configuration.nameservers = { [".,0-9a-zA-Z]+ }`)
|
r := regexp.MustCompile(`configuration.nameservers = { [".,0-9a-zA-Z]+ }`)
|
||||||
return r.MatchString(cfg)
|
return r.MatchString(cfg)
|
||||||
|
|
Loading…
Reference in a new issue