I am trying to create some custom error pages but cannot make 500 work.
I have the following configuration:
server { listen 80; root /var/www/devsite; index index.php; server_name devsite; error_page 403 = /error.php?code=403; error_page 404 = /error.php?code=404; error_page 500 = /error.php?code=500; location / { try_files $uri =404; } location ~ \.php$ { try_files $uri =404; fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; include fastcgi_params; } }
At first I thought it could be because it is a PHP file, so I changed:
error_page 500 = /error.php?code=500;
To static page:
error_page 500 /500.html
But it still just shows a blank page with a 500 response code when I interrupt some PHP code to call it.
Then I tried to make this the last rule inside location ~ \.php$ , but the same thing will happen. Any ideas why the custom page 500 won't work?
I also notice that if you try to access a file with a deny access that has the extension .php, it will not show the user page 403 and will not show the embedded page. Is there a way to make a rule also closed .php files?
source share