Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.
SOLVED

Issue with error page in the dispatcher

Avatar

Level 4

Hi, 

 

I am having trouble with redirecting visitors to an error page that is located within the dispatcher itself. The use case for this would be to send visitors to a very general error page when AEM is entirely down/maintenance is in progress. I have read elsewhere in other posts that the best way around this would be to place an html error page within the dispatcher. 

 

The DispatcherPassError is set to 1 in the vhost. We also have localized error pages set up and working great. My issue is when I create the html file within the Dispatcher, and route the dispatcher to this file on 404, I get a Not Found with this message: "error was encountered while trying to use an ErrorDocument to handle the request."

 

It is very possible I am placing the html file in the wrong location as well. Could someone assist with best practices on what directory this error file should reside within the dispatcher, or send a link to some documentation on this specific tasks?

 

Thanks

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

@mmasonWD In case your application or publisher is down and going through the maintenance, use the approach mentioned here in this link. You can simply route your site requests to dispatcher error page

 

https://labs.tadigital.com/index.php/2018/06/15/implementing-maintenance-mode-for-a-production-relea... 

 

Let me know if this help!

View solution in original post

10 Replies

Avatar

Community Advisor

@mmasonWD : 

 

Apart from configuring DispatcherPassError is set to 1, you have to define the ErrorDocument directive in Apache which tells it about where the error page is (OR) what should be displayed upon receiving an error.
The syntax of the ErrorDocument directive is:

ErrorDocument <3-digit-code> <action>

where the action will be treated as:

1.A local URL to redirect to (if the action begins with a “/”).
2.An external URL to redirect to (if the action is a valid URL).
3.Text to be displayed (if none of the above). The text must be wrapped in quotes (“) if it consists of more than one word.

For example, if you have the error page in /content/site1 location then the ErrorDocument in this site’s vhost file can be given as:

ErrorDocument 404 /content/site1/404.html

ErrorDocument 500 /content/site1/500.html

(OR) specify the URL to which the error page should land to,

ErrorDocument 500 http://error.example.com/server_error.html

 

Please refer to the below post that describes the error handling on AEM sites.

https://labs.tadigital.com/index.php/2018/01/16/error-handling-using-a-dispatcher/ 

Avatar

Level 4

Hi, 

 

What you explained and mentioned above is currently working for us. But not what I am looking for unfortunately.

 

We have our ErrorDocument 404 and 500 set up properly, as mentioned, and are working great.

 

What we are trying to do now for the <action> is to link an error page that is located in the dispatcher itself (not AEM). My question is where should I place this error page file within the dispatcher? Currently I have the error page located in /mnt/var/www/html/content/*host*/error/errorpage.html

 

The syntax we then have for this is: ErrorDocument 404 /error/errorpage.html

 

This unfortunately is not working. I also feel confident this is in the wrong location, as when the dispatcher is cleared, it will delete this file, so this was mostly for testing purposes. 

Avatar

Community Advisor

@mmasonWD When dispatcher cache is cleared, it will also delete the error page that is placed in the dispatcher cache path but in case you are trying for any debugging purpose, try with giving the entire path

 

ErrorDocument 404 /content/*host*/error/errorpage.html

Avatar

Level 4

@Avinash_Gupta_ are there some best practices on exactly where this custom error page should live within the dispatcher, what directory is recommended?

 

Also, the change you recommended me make, something odd is happening. When I type in the URL a page that doesn't exist, it is now giving 301 and 307 redirects and looping which causes an ERR_TOO_MANY_REDIRECTS. This could be caused by some rewrite condition that I will have to look further into. 

Avatar

Community Advisor

@mmasonWD Generally, these error pages are created on AEM side and it's get cached inside dispatcher path /var/www/html. When we define a below statement in the dispatcher rules, in case of 404 error, it will refer to first to error page path cached inside dispatcher and if it's not available, it will get it from publisher and cached it in dispatcher.

ErrorDocument 404 /content/site1/404.html

 

Manually these error pages shouldn't be created in dispatcher as dispatcher flush is going to clear these pages. For debugging you can create these pages on the web server and verify the functionality.

 

Refer to the below link in which examples are given to create a custom page on Apache webserver.

https://www.digitalocean.com/community/tutorials/how-to-configure-apache-to-use-custom-error-pages-o... 

Avatar

Level 4

@Avinash_Gupta_ Again, this is for when the Publisher is down entirely and the dispatcher can't serve the error pages from the Publisher, for AMS Maintenance or other critical conditions. 

 

Thanks for the article. Unfortunately I have everything on my end set up exactly as it is within the article you shared. I suspect there may be a rewrite or redirect condition on our end that is causing issues. 

Avatar

Correct answer by
Community Advisor

@mmasonWD In case your application or publisher is down and going through the maintenance, use the approach mentioned here in this link. You can simply route your site requests to dispatcher error page

 

https://labs.tadigital.com/index.php/2018/06/15/implementing-maintenance-mode-for-a-production-relea... 

 

Let me know if this help!

Avatar

Level 4

Hi, this what Avinash had recommended above as well. But is not what the issue is. our ErrorDocument syntax is setup and working well. But we are wanting to do additionally is to link an error page that is living within the dispatcher, which is causing issues as mentioned above.