L
L
littleguga2015-12-19 14:01:40
Nginx
littleguga, 2015-12-19 14:01:40

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;
        }

}

As a result, it still displays the default error page.
What could be the problem?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
L
littleguga, 2015-12-21
@littleguga

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;
}

Y
Yuri, 2015-12-19
@xtreme

I would venture to suggest that the matter is in the absence fastcgi_intercept_errors on;in the section with php.
nginx.org/ru/docs/http/ngx_http_fastcgi_module.htm...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question