【问题标题】:What's the best way to redirect a Tomcat 404 URL with Apache as front-end?使用 Apache 作为前端重定向 Tomcat 404 URL 的最佳方法是什么?
【发布时间】:2017-01-14 13:59:11
【问题描述】:

我有 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

这可行,除非我退出 web 应用程序,否则我会收到 Tomcat 报告的以下 404:

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

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

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

【问题讨论】:

    标签: apache tomcat guacamole


    【解决方案1】:

    对于偶然发现此问题的任何人,我都能从 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>
    

    我确信有一种更清洁的方法可以做到这一点,但目前对此的要求很低,这可以抚平粗糙的边缘。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-06-18
      • 2016-08-06
      • 1970-01-01
      • 2015-07-28
      • 1970-01-01
      • 1970-01-01
      • 2012-01-08
      • 1970-01-01
      相关资源
      最近更新 更多