Answer the question
In order to leave comments, you need to log in
Why is error_page not working in nginx?
There is this configuration:
server {
server_name "mysite.ru";
root "/var/www/mysite/";
###
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
#Errors
error_page 400 /errors/index.php?400;
error_page 403 /errors/index.php?403;
error_page 404 /errors/index.php?404;
error_page 500 /errors/index.php?500;
location = /errors/ {
root "/var/www/common";
internal;
}
}
Answer the question
In order to leave comments, you need to log in
The answer turned out to be simple: you need to read the docks more carefully. (I didn’t specify directives for fastcgi)
Something like this:
location = /errors/index.php {
root "/var/www/common";
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
internal;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question