Remove localhost calls from external names

Signed-off-by: Ricardo Pchevuzinske Katz <ricardo.katz@gmail.com>
This commit is contained in:
Ricardo Pchevuzinske Katz 2021-04-30 00:24:28 -03:00
parent 22ae0d3848
commit 0dceedfad7
6 changed files with 74 additions and 1 deletions

View file

@ -35,6 +35,9 @@ local IMPLEMENTATIONS = {
ewma = ewma,
}
local PROHIBITED_LOCALHOST_PORT = configuration.prohibited_localhost_port or '10246'
local PROHIBITED_PEER_PATTERN = "^127.*:" .. PROHIBITED_LOCALHOST_PORT .. "$"
local _M = {}
local balancers = {}
local backends_with_external_name = {}
@ -317,6 +320,11 @@ function _M.balance()
return
end
if peer:match(PROHIBITED_PEER_PATTERN) then
ngx.log(ngx.ERR, "attempted to proxy to self, balancer: ", balancer.name, ", peer: ", peer)
return
end
ngx_balancer.set_more_tries(1)
local ok, err = ngx_balancer.set_current_peer(peer)