Introduction
In this article, we discuss creating custom error pages for use with the cPanel provided nginx.
Procedure
Before modifying any files indicated below, it is important that you backup those files up so that you may revert your configuration should the need arise.
- First, create a file at
/var/www/html/
or/usr/share/nginx/html/
containing your custom error page. This can be named anything you would like, but I recommend something similar to custom_###.html; Where ### is the error code. - Next, create a file at
/etc/nginx/conf.d/server-includes/error-pages.conf
containing the following:error_page ### /custom_###.html;
Where $path is the chosen path from step 1.
location /custom_###.html {
root $path;
} - Finally, restart Apache and ea-nginx using their respective restart scripts:
/usr/local/cpanel/scripts/restartsrv_httpd
/usr/local/cpanel/scripts/restartsrv_nginx
Once completed your custom error pages will appear whenever it is appropriate for them to do so.
If you would like your custom error page to appear for multiple error codes simply include them after the error_page directive. As an example:
error_page 404 413 502 503 /custom_###.html;