Reputation: 68
I have trouble with Tomcat 9 configuration on Ubuntu. I have deployed 1 application under Tomcat. Created SSL and redirect HTTP to HTTPS. My appliaction name for example - example :) So I have this:
Part of my server.xml config file:
<Connector port="80" protocol="HTTP/1.1"
connectionTimeout="60000"
redirectPort="443"
enableLookups="false"
useBodyEncodingForURI="true"/>
<Connector port="443" protocol="HTTP/1.1"
maxThreads="150"
SSLEnabled="true"
scheme="https"
secure="true"
clientAuth="false"
sslProtocol="TLS"
keystoreFile="path to cert"
keystoreType="PKCS12"
keystorePass="cert password"/>
and in EOF of web.xml i have:
<security-constraint>
<web-resource-collection>
<web-resource-name>Protected Context</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<user-data-constraint>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
</security-constraint>
Redirect works fine, when I type http://localhost I automatically will be redirected to HTTPS, but only if I type http://localhost. When I type http://localhost/example - redirect doesn't work, why?
So, I add to index.jsp in webapps/ROOT:
<%
String redirectURL = "/example";
response.sendRedirect(redirectURL);
%>
redirect work fine
So, I would like to permanent redirect "example" to root, so I added to my server.xml content:
<Context path="" docBase="example" debug="0" reloadable="true"></Context>
Redirect work fine, when I type http://localhost I see content of example. But there is problem - HTTP - HTTPS redirect doesn't work after add "context". Why? I spent half a day with Tomcat configuration and I don't know why redirect doesn't work after adding context.
Upvotes: 0
Views: 984