Can tomcat perform ssl redirection by filtering host alias?

Posted by Stephen on Stack Overflow See other posts from Stack Overflow or by Stephen
Published on 2010-06-09T11:29:54Z Indexed on 2010/06/09 11:32 UTC
Read the original article Hit count: 195

Filed under:
|
|
|

Hi,

We have a tomcat server (6.0.20) running one web application behind two urls, e.g. www.foo and secure.foo

This is configured in the server.xml as one host with a single alias:

<Host name="www.foo" appBase="webapps">
    <Context docBase="foo" path=""></Context>
    <Alias>secure.foo</Alias>
</Host>

Ideally we'd like any requests to secure.foo on port 80 to be automatically redirected to use ssl. However, I can only find instructions for redirecting based on the path after the hostname, so I could add a /* security constraint but then this would apply to both urls.

Does anyone know if it's possible to apply the redirection by filtering on hostname requested?

(We've already got the ssl connector, certificate, etc. working ok).

I know we could do it by sticking an apache server in front of tomcat and handling the redirection there, but I'm curious to know if tomcat can do this on its own.

Thanks

© Stack Overflow or respective owner

Related posts about apache

Related posts about tomcat