Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug when auth req is enabled(external authentication) #2280

Merged
merged 2 commits into from
Mar 30, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions internal/file/bindata.go

Large diffs are not rendered by default.

8 changes: 7 additions & 1 deletion rootfs/etc/nginx/lua/balancer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
6 changes: 5 additions & 1 deletion rootfs/etc/nginx/template/nginx.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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 "";
Expand Down