proxyauth: redirect correctly after login

This commit is contained in:
Girish Ramakrishnan
2020-11-10 23:39:57 -08:00
parent 045963afe5
commit 008fa09877
2 changed files with 9 additions and 6 deletions

View File

@@ -162,9 +162,9 @@ server {
<% if (proxyAuth.enabled) { %>
proxy_set_header X-App-ID "<%= proxyAuth.id %>";
location = /auth {
location = /proxy-auth {
internal;
proxy_pass http://127.0.0.1:3001;
proxy_pass http://127.0.0.1:3001/auth;
proxy_pass_request_body off;
proxy_set_header Content-Length "";
}
@@ -173,7 +173,9 @@ server {
proxy_pass http://127.0.0.1:3001;
}
error_page 401 403 /login;
location @proxy-auth-login {
return 302 /login?redirect=$request_uri;
}
<% } %>
location / {
@@ -235,9 +237,10 @@ server {
}
<% } else if ( endpoint === 'app' ) { %>
<% if (proxyAuth.enabled) { %>
auth_request /auth;
auth_request /proxy-auth;
auth_request_set $auth_cookie $upstream_http_set_cookie;
add_header Set-Cookie $auth_cookie;
error_page 401 = @proxy-auth-login;
<% } %>
proxy_pass http://127.0.0.1:<%= port %>;