Nginx

Create Custom Page For 403 Forbidden Error Message In Nginx

Question : Can I create a custom error page for 403 forbidden error message.

Answer : Yes If you are using unlimited hosting plan, you can create a customised 403 error page. Follow the below steps to create 403 page in Nginx.

Create A Custom 403 Error Page

To create your custom 403 error page, here’s what you will need to do:

1. Create your own custom 403 error page, for example call it 403.html on your default web document root.

# cd /var/www/html/
# vim 403.html

<html>
<head><title>Error 403 - You are not authorized to access this page.</title></head>
<body>
You are not authorized to access this page. If you this an error, please contact webmaster with your IP at [email protected]
</body>
</html>

2. Edit your nginx.conf file like below:

# vim nginx.conf
# redirect server error pages to the static page
 error_page   403  /403.html;
 location = /403.html {
         root   /var/www/html;
 }

3. Save and closer file.

4. Restart and reload the Nginx service.

 # service nginx reload/restart

5. Visit your website to a unauthorised page to confirm if the error page is working correctly.

Thanks:)

Thank you! for visiting LookLinux.

If you find this tutorial helpful please share with your friends to keep it alive. For more helpful topic browse my website www.looklinux.com. To become an author at LookLinux Submit Article. Stay connected to Facebook.

About the author

mm

Santosh Prasad

Hi! I'm Santosh and I'm here to post some cool article for you. If you have any query and suggestion please comment in comment section.

1 Comment

  • Thanks Jamie for feedback, Please let me know which part is confusing. I will try to make it easy. Sorry for your bad experience on site.

Leave a Comment