本文介绍了用Apache作为前端重定向Tomcat 404 URL的最佳方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有Apache 2.4将*:80流量转发到我唯一的Tomcat 7.0 webapp(鳄梨调味酱),如下所示:

I have Apache 2.4 forwarding *:80 traffic to my sole Tomcat 7.0 webapp (Guacamole) like so:

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

此方法有效,除了注销Web应用程序外,我得到了Tomcat报告的以下404消息:

This works, except when I log out of the webapp, I get the following 404 as reported by Tomcat:

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

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

From what I've read I've got several options, including using ProxyPass/redirect, rewrite, VirtualHost, and symlinks. Some of these options are possible under both Apache and Tomcat configs. I'm confused. What's the best method to ensure /guacamole/guacamole/index.xhtml (or *) requests get to to /guacamole/index.xhtml?

(我不知道Java是不是真正的根本原因在于Guacamole Webapp代码.)

(I know no Java if the actual root cause is in the Guacamole webapp code.)

推荐答案

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

To anyone who stumbles across this issue, I was able to resolve from Suresh Atta's answer to this question.

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

Basically all that I had to do was create a custom 404 html in /var/lib/tomcat/webapps/guacamole/logout.html which contains a polite message and invitation to log in again:

<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:

And then I added this directive to web.xml:

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

我敢肯定有一种更简洁的方法可以做到这一点,但是目前对此的要求很低,这使粗糙的边缘变得更加光滑.

I'm sure there's a little cleaner way to do this, but the requirements are low for this right now, and this smoothed the rough edge.

这篇关于用Apache作为前端重定向Tomcat 404 URL的最佳方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-24 15:44