How to Redirect all http requests to https on Tomcat by default
Posted by Ashraf on November 23, 2010
***Considering that you already enable SSL with proper certificate.
To auto redirect all of your webserver requests from http to https just paste the following to your tomcat installation folder\conf\web.xml file and restart the service.
<security-constraint>
<web-resource-collection>
<web-resource-name>Protected Context</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<!– auth-constraint goes here if you requre authentication –>
<user-data-constraint>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
</security-constraint>
Now browse http://localhost and it will automatically go to https://localhost , for example.
This entry was posted on November 23, 2010 at 4:21 pm and is filed under System Administration, Windows Server. Tagged: Certificate authority, HTTP Secure, SSL, Tomcat, Transport Layer Security, Web server. You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed.
Sorry, the comment form is closed at this time.