kiwisan kiwisan - 2 months ago 16
Apache Configuration Question

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

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


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


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
?

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

Answer

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

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>

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.

Comments