Customize the Nginx error message

Asked

Viewed 888 times

1

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

I installed from this tutorial: http://www.nginxcp.com/installation-instruction

What I wanted was to put a message in Portuguese for "lay" users. It has some form to customize?

1 answer

2

All errors can be modified.

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

I’ll put this in the directory /usr/share/nginx/error/, this will prevent you from accessing the meusite.com/500.html shows the error, by default the directory of the site is the 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 the Centos.

For a better demonstration you should have 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;
        }

    //...

}
  • I will take a test and post the result! Thank you very much for your reply!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.