【发布时间】:2015-12-25 08:55:29
【问题描述】:
我已在我的 Web 应用程序中配置 SSL。我已按照所需步骤在我的 Tomcat 中安装了证书。
我一直在关注的教程是 https://www.mulesoft.com/tcat/tomcat-security
我已强制使用 https 而不是 http,这意味着对 http 的任何请求都将转发到 https。我在 server.xml 中进行了以下更改
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="443"
proxyHost="10.1.1.1" proxyPort="80"
URIEncoding="UTF-8"
maxHttpHeaderSize="32768"/>
web.xml更改如下:
<security-constraint>
<web-resource-collection>
<web-resource-name>SecureConnection</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<user-data-constraint>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
</security-constraint>
但是,正在发生的重定向是临时重定向,即 302。 我想使用 301 重定向,即永久重定向。
我怎样才能做到这一点?
【问题讨论】:
-
您找到这个问题的答案了吗?我也有同样的问题。
-
同上,这个问题有进展吗?
-
对于现在只想“强制执行 https tomcat”、“始终使用 https tomcat”或类似内容的 Google 员工,这就是解决方案。 jelastic.zendesk.com/hc/en-us/community/posts/…也提供了解决方案。
-
可以通过urlrewritefilter实现,但是设置
<to type="permanent-redirect">...。与jelastic.zendesk.com/hc/en-us/community/posts/… 中概述的第二个选项一起,它构成了一个完整的解决方案。