使用 Apache 作为前端重定向 Tomcat 404 URL 的最佳方法是什么?

What's the best way to redirect a Tomcat 404 URL with Apache as front-end?

我有 Apache 2.4 转发 *:80 流量到我唯一的 Tomcat 7.0 webapp (Guacamole) 像这样:

ProxyPreserveHost On
ProxyRequests off
ProxyPass / http://localhost:8080/guacamole/
ProxyPassReverse / http:/localhost:8080/guacamole/
ProxyPassReverseCookiePath / http://localhost:8080/guacamole

这有效,除了当我注销 webapp 时,我收到 Tomcat 报告的以下 404:

HTTP Status 404 - /guacamole/guacamole/index.xhtml

根据我的阅读,我有几种选择,包括使用 ProxyPass/redirect、重写、VirtualHost 和符号链接。其中一些选项在 Apache 和 Tomcat 配置下都是可能的。我很困惑。确保 /guacamole/guacamole/index.xhtml(或 *)请求到达 /guacamole/index.xhtml 的最佳方法是什么?

(我不知道 Java 真正的根本原因是否在 Guacamole webapp 代码中。)

对于偶然发现此问题的任何人,我能够从 Suresh Atta 的回答中解决 to this question

基本上我所要做的就是在 /var/lib/tomcat/webapps/guacamole/logout.html 中创建一个自定义 404 html,其中包含礼貌的消息和再次登录的邀请:

<html>
<h2 align=center>Thank you. You're now logged out.</h2>
<h2 align=center>If this was a mistake or you'd like to begin a new session, 
please <a href="http://guacamoleapp.address.com">click here.</a></h2>
</html>

然后我将此指令添加到 web.xml:

<error-page>
  <error-code>404</error-code>
  <location>/logout.html</location>
</error-page>

我敢肯定有更简洁的方法可以做到这一点,但现在对它的要求很低,并且这消除了粗糙的边缘。