I have the following directory scheme
/srv/www/htdocs/www/
where www is the public directory root, and htdocs contains files outside the public access. This is the nginx.conf
server {
listen 443 ssl http2;
root /srv/www/htdocs/www;
location / {
index index.php;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_intercept_errors on;
include fastcgi_params;
}
error_page 401 @errorPage;
error_page 403 @errorPage;
error_page 404 @errorPage;
location @errorPage {
root /srv/www/htdocs;
rewrite ^ error.php?error=$status last;
}
}
What I'm trying to do is to serve the error.php page when 401,403 and 404 triggers, but still I'm getting the default Nginx 404 page, even when I programmatically trigger 403 or 401.
Am I doing something wrong in the named location?