I do auth_request /auth;
as described in https://docs.nginx.com/nginx/admin-guide/security-controls/configuring-subrequest-authentication/
How can I redirect to login page if /auth returns 401 or 403?
I tried with
error_page 401 403 = @error401;
location = ^/securedUrl {
add_header dbg-header dbg_ws_3;
auth_request /auth;
proxy_pass http://auth-module:8080;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_pass_header x-remaining-session-time;
}
location @error401 {
return 302 /login-module/login;
}
location = /auth {
internal;
rewrite ^/(.*) /is-authorized break;
proxy_pass http://auth-module:8080;
proxy_pass_request_body off;
proxy_set_header Content-Length "";
proxy_set_header X-Original-URI $request_uri;
}
but it doesn't work, I get 401 in browser
as described in https://docs.nginx.com/nginx/admin-guide/security-controls/configuring-subrequest-authentication/
How can I redirect to login page if /auth returns 401 or 403?
I tried with
error_page 401 403 = @error401;
location = ^/securedUrl {
add_header dbg-header dbg_ws_3;
auth_request /auth;
proxy_pass http://auth-module:8080;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_pass_header x-remaining-session-time;
}
location @error401 {
return 302 /login-module/login;
}
location = /auth {
internal;
rewrite ^/(.*) /is-authorized break;
proxy_pass http://auth-module:8080;
proxy_pass_request_body off;
proxy_set_header Content-Length "";
proxy_set_header X-Original-URI $request_uri;
}
but it doesn't work, I get 401 in browser