We have an comples nginx reverse proxy setup with multiple upstreams. Every config includes 'auth.conf', sending every request to an authentication backend.
auth_request /auth;
error_page 401 = @error401;
error_page 403 = @error403;
location /auth {
proxy_pass_request_body off;
proxy_set_header Content-Length "";
set $baseurl_auth authorization-service.local;
proxy_pass https://$baseurl_auth:8443/authorize;
}
location @error401 {
return 302 https://$host/logout;
}
location @error403 {
}
We want to display an customized 403 page. We have tried several ways like:
location @error403 {
root /var/www/localhost/htdocs;
try_files /403.html =403;
}
Still getting default 403 from nginx.
Only solutions, working so far:
location @error403 {
add_header Content-Type text/html;
return 200 '<html><body>Access denied</body></html>';
}
but we need a fully styled page and maybe proper http return codes.