401 / 403 / 500 Error Pages


(Douglas (@finnatic at @waikato)) #1

Are there any best practice guidelines around 401 / 403 / 500 Error handling with Squiz Matrix Web CMS servers?

I’m aware you can set a global 404 via the remap manager inside Matrix, but I’m thinking both in terms of within Matrix (it’s nice being able to have Matrix content editors manager their own error pages) but also external in terms of Apache or Nginx config.


#2

I am interested to see how to do this as well. Other than global 404, I don’t know how to make Squiz Matrix to return correct HTTP status code (403 for example).


(Bart Banda) #3

Well, some error responses are returned by the web server right? Such as 401 and 500? They don’t even hit Matrix so there would be no way for Matrix to control that.

403 is already handled by Matrix as that is essentially the login design that you get when you don’t have access to a page.

So except for 403, the other error codes mentioned above would need to be handled via server configuration settings afaik.


(Douglas (@finnatic at @waikato)) #4

Agreed and accepted that Matrix is only responsible for some status code handling - I think my query could be answered easily through a more detailed Apache config on https://matrix.squiz.net/resources/installation-guides/manual-installation-guide along with sample Nginx config files.

E.g. we’ve had some limited success in Apache with 401 config like:

Alias "/401.html" "/home/websites/uow/401.html"
ErrorDocument 401 /401.html

but we need to review, correct and improve what we’ve got there, and we’re still in our early days with Nginx.


#5

Hi Bart, that’s true. The HTTP status code is handled by the web server. However, PHP (which is the language Matrix is built on) has the functionality to ask the server to return certain HTTP status code. I was expecting some options to make the page return certain HTTP status code, for example by making Matrix to execute something like this:

header($_SERVER['SERVER_PROTOCOL'] . ' 500 Internal Server Error', true, 500);

Douglas, in your case if you have access to the Nginx configuration file, yes you can use it to achieve what you need.


(Douglas (@finnatic at @waikato)) #6

we do - we had a need to fix the 404 setup, as nginx was returning the wrong status code (200), which has me considering what we might do for other status codes which Matrix is expecting the httpd server to handle.


(Bart Banda) #7

Maybe it’s better to have a look at some nginx guides online? For example, https://www.linode.com/docs/web-servers/nginx/how-to-configure-nginx

Maybe in the future we could add some default status pages for those error codes and provide default nginx configs to match, but that stuff is currently all handled by Squiz Hosting and separately outside of the software.


#9

You can set the 403 & 404 pages in the site’s details page, they can be any page you fancy and you can allow your editors edit them as they wish. For the rest, they are controlled by server.