Page 1 of 1

Server not showing 404 error page.

Posted: Mon Oct 16, 2017 6:53 pm
by Trentor
Hello.

I am trying to use a custom error pages on my server, but I can't even see the default ones.

For example, if I write a wrong address, http://mydomain.tld/testing404, the result is:

Image

So, my server is not reading the default error pages.

CentOS 7
Apache + Nginx

Re: Server not showing 404 error page.

Posted: Sat Nov 16, 2019 1:48 am
by tavinus
Hi there.
I was with the same problem so I thought I should post how I fixed it.

My config is using nginx + apache (I think the OP had the same config).
I am also using https redirect template in nginx.

First thing to try is to see if the redirection to the error pages is working.
To do that, just open:
https://yourdomain.com/error/404.html

This should work! You should see a vesta style 404 error page instead of the Apache one.
If it does not work, you need to fix your aliases on nginx and/or apache.

Now we need to fix the config to point to the correct page.
I was looking in nginx for hours and then realised that the error pages come from apache.

There are 2 ways to add the config: .htaccess OR change apache config file.

The easier way is to just add a .htaccess to the webroot with the contents:

Code: Select all

ErrorDocument 403 /error/404.html
ErrorDocument 404 /error/403.html
ErrorDocument 500 /error/50x.html
ErrorDocument 502 /error/50x.html
ErrorDocument 503 /error/50x.html
ErrorDocument 504 /error/50x.html
That is it! Done!

The other way is to edit the config file (may lose changes if changing config later).
The file sits in /home/USER/conf/web/DOMAIN.TLD.apache2.ssl.conf
(this will probably need a apache service reload as well)
Just add the same contents of the .htaccess file inside your virtualServer.
Apache docs: https://httpd.apache.org/docs/2.4/custom-error.html

To customize the error pages for each user, change the files in
/home/USER/web/DOMAIN.TLD/document_errors

To change the error pages templates (that are installed to new accounts)
/usr/local/vesta/data/templates/web/skel/

I guess the template needs to be fixed.
Not sure if it works fine with other configs (not apache + nginx + https redirect).

Some times nginx and apache may cache the results, requiring you to reload/restart to see the changes.

Cheers!
Gus