Custome 404 page not found in NGINX
Hi there,
Welcome to Binary Stack blog. Today I will discuss " How To Configure Nginx to Use Custom Error Pages"
Before getting started, let's know about NGINX
Nginx is a high-performance web server capable of serving content with flexibility and power. When designing your web pages, it is often helpful to customize every piece of content that your users will see. This includes error pages for when they request content that is not available. In this guide, we’ll demonstrate how to configure Nginx to use custom error pages on Ubuntu.
To get started on, you will need a non-root user with Sudo privileges.
Create custom error page in the path /usr/share/nginx/html where Ubuntu’s Nginx sets its default document root. Make a page for 404 errors called custom_404.htmlFor example:
/> cd /usr/share/nginx/html
/> vi custm-404.html (Note: you can use your favourite editor)
Now You need to update NGINX config file:
Probably NGINX conf file path are: /etc/nginx/nginc.conf
Add following line into nginx.conf file
error_page 404 /custom_404.html;
location = /custom_404.html {
root /usr/share/nginx/html;
internal;
}
Now Restart NGINX and you are done.
Please write a comment if this was helpful or not!!! Thank you
Very Helpful
ReplyDelete