Tomcat https 重定向(安全约束)针对不同的主机



>我正在尝试将调用从http重定向到https,因此:

在我的服务器中.xml我有两个主机:

<Host name="localhost"  appBase="webapps"
        unpackWARs="true" autoDeploy="true">
 ...
  </Host>
  <Host name="other.name" appBase="/srv/webapp" 
        unpackWARs="true" autoDeploy="true">
  ...
  </Host>

我在/etc/tomcat7/web.xml 上添加了:

<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>

因此,所有将发送到本地主机的请求都将重定向到 https,但是将要 other.name 的请求不会被重定向。

我想要的只是 other.name 重定向到 https 的请求,我该怎么做?

我试着把

<url-pattern>other.name/*</url-pattern>

但没有用。有什么建议吗?

我从/etc/tomcat7/web.xml中删除了<security-constraint>,并添加到我的 Web 应用程序的WEB-INF/web.xml中。

最新更新