Customize 404 error page for Synology WebStation (en)
Tested on DSM 6.2.2-24922 Update 4
The default web server used by WebStation is nginx.
Each time WebStation is restarted, the configuration files are regenerated in order to avoid any error that could block the operation of WebStation. Configuration files are created from mustache template.
The mustache template for configuring error pages can be found in the directory :
/var/packages/WebStation/target/misc/
This is the file :
/var/packages/WebStation/target/misc/nginx_web_error_page.mustache
This model generates the configuration file used by nginx :
/etc/nginx/app.d/server.webstation-vhost.conf
The content of the mustache model is :
error_page 400 401 402 403 404 405 406 407 408 500 501 502 503 504 505 @error_page;
location @error_page {
root /var/packages/WebStation/target/error_page;
rewrite ^ /$status.html break;
}
You can modify it as follows :
error_page 400 401 402 403 405 406 407 408 500 501 502 503 504 505 @error_page;
error_page 404 /404.html;
location @error_page {
root /var/packages/WebStation/target/error_page;
rewrite ^ /$status.html break;
}
Then the file in the root of the web server directory named 404.html will be displayed as a 404 error file. The root of the site is not /volume1/web/
, that is to say the shared folder, but /volume1/web/mywebsite
if the directory /mywebsite/
contains the files for your site.