Fix bug when auth req is enabled(external authentication) (#2280)
* set proxy_upstream_name correctly when auth_req module is used * log a more meaningful message when backend is not found
This commit is contained in:
parent
bcb162ac0f
commit
931e541fb7
3 changed files with 14 additions and 4 deletions
File diff suppressed because one or more lines are too long
|
@ -27,7 +27,13 @@ end
|
|||
|
||||
local function get_current_backend()
|
||||
local backend_name = ngx.var.proxy_upstream_name
|
||||
return backends:get(backend_name)
|
||||
local backend = backends:get(backend_name)
|
||||
|
||||
if not backend then
|
||||
ngx.log(ngx.WARN, "no backend configuration found for " .. tostring(backend_name))
|
||||
end
|
||||
|
||||
return backend
|
||||
end
|
||||
|
||||
local function get_current_lb_alg()
|
||||
|
|
|
@ -738,7 +738,11 @@ stream {
|
|||
{{ if $authPath }}
|
||||
location = {{ $authPath }} {
|
||||
internal;
|
||||
set $proxy_upstream_name "external-authentication";
|
||||
|
||||
# ngx_auth_request module overrides variables in the parent request,
|
||||
# therefore we have to explicitly set this variable again so that when the parent request
|
||||
# resumes it has the correct value set for this variable so that Lua can pick backend correctly
|
||||
set $proxy_upstream_name "{{ buildUpstreamName $server.Hostname $all.Backends $location }}";
|
||||
|
||||
proxy_pass_request_body off;
|
||||
proxy_set_header Content-Length "";
|
||||
|
|
Loading…
Reference in a new issue