Enabling custom 403 error docs with nginx in Plesk

Please note that in order to complete these steps you must have admin access to Plesk.

While you would think that enabling “Custom Error Docs” under hosting settings in Plesk, then editing the appropriate document under the /error_docs/ folder in your vhost root would do the trick, unfortunately that’s not the case. Those error documents are seemingly only capable of being loaded by Apache.

If you’ve specified IP allows/denies using Plesk 12+ then it’s using nginx to handle those denies. This is great for performance and resource consumption, but not great when it comes to compatibility with features initially configured for apache use, like custom error documents.

I tried placing the standard error_page directive at every level of the vhost’s nginx config and it did not work anywhere.

The only solution I found that worked was to redirect to an external URL:

error_page 403 = @forbidden;
location @forbidden {
 return 302 http://{secondary_domain}/forbidden.html;

If you don’t have another domain to use, the simplest fix is to create a subdomain to enter there, like errors.mydomain.com. Once you have your error doc in the right place (the secondary domain’s web root in the case of the path above), simply insert the abovec code in the domain’s “Additional nginx directives” box (under Apache & Nginx settings). That box is provided only to Plesk admins.

About Jordan Schelew

Jordan has been working with computers, security, and network systems since the 90s and is a managing partner at Websavers Inc. As a founder of the company, he's been in the web tech space for over 15 years.

Leave a Comment