我已成功将Tomcat配置为从端口80重定向到443.但是,Tomcat是否足够智能,只允许将某些端点重定向到443,同时允许其他端点访问端口80?
例如,我只希望将从http://myWebsite/myBankAccount/ *到达的端点重定向到https。但是如果您只是访问http://myWebsite.com,Tomcat将允许端口80访问。
如果Tomcat不够聪明,那么应用程序可以做什么?
答案 0 :(得分:2)
您可以使用url-pattern
元素。这是一个例子:
<!-- Require HTTPS for everything that matches the url pattern: /myBankAccount/* -->
<security-constraint>
<web-resource-collection>
<web-resource-name>HTTPSOnly</web-resource-name>
<url-pattern>/myBankAccount/*</url-pattern>
</web-resource-collection>
<user-data-constraint>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
</security-constraint>