Customize the Nginx error message

1

Hello, the Nginx server has a message that pops up from time to time on sites like 502 Bad Gateway . Can you customize this message via SSH in Nginx files?

  

I've installed from this tutorial: link

What he wanted was for a message in Portuguese for "lay" users. Do you have any way to customize?

    
asked by anonymous 11.09.2016 / 04:52

1 answer

2

All errors can be modified.

First create a file and give it a name, for example: 500.html .

I'll put this in the /usr/share/nginx/error/ directory, this will prevent access to meusite.com/500.html from displaying the error, by default the site directory is usr/share/nginx/html/ . ;)

Change the settings to:

error_page 502 /500.html;
location = /500.html {
        root /usr/share/nginx/error;
}

Normally, the directory of the file you should change is /etc/nginx/conf.d/default.conf , in CentOS.

For better demonstration should look something like this:

server {
    listen       80;
    server_name  meusite.com.br;

        location / {
               root   /usr/share/nginx/html;
               index index.php  index.html index.htm;
        }


        error_page 502 /500.html;
        location = /500.html {
                root /usr/share/nginx/error;
        }

    //...

}
    
11.09.2016 / 07:07