Fix sticky session for ingress without host

This commit is contained in:
Manuel Alejandro de Brito Fontes 2019-12-28 19:56:13 -03:00
parent 8db541e24b
commit 6c92c80073
4 changed files with 75 additions and 5 deletions

View file

@ -82,11 +82,16 @@ local function get_failed_upstreams()
end
local function should_set_cookie(self)
if self.cookie_session_affinity.locations and ngx.var.host then
local locs = self.cookie_session_affinity.locations[ngx.var.host]
local host = ngx.var.host
if ngx.var.server_name == '_' then
host = ngx.var.server_name
end
if self.cookie_session_affinity.locations then
local locs = self.cookie_session_affinity.locations[host]
if locs == nil then
-- Based off of wildcard hostname in ../certificate.lua
local wildcard_host, _, err = ngx.re.sub(ngx.var.host, "^[^\\.]+\\.", "*.", "jo")
local wildcard_host, _, err = ngx.re.sub(host, "^[^\\.]+\\.", "*.", "jo")
if err then
ngx.log(ngx.ERR, "error: ", err);
elseif wildcard_host then