使用不同的网络端口从服务器运行http和https

时间:2019-10-15 16:04:25

标签: tomcat9 hsts

我有多台具有独立配置的tomcat服务器,它们在同一服务器的不同端口上运行。最近将几个tomcat服务器从http转换为https。所以奇怪的问题是:

应用程序1:在https://x.y.z.w:10001(https)上运行 应用程序2:运行在http://x.y.z.w:8888(http)

如果我首先从浏览器(chrome / firefox)访问Application 2,则它运行正常。

如果我先访问应用程序1,然后再访问应用程序2,则应用程序2 URL将自动更改为 https ://x.y.z.w:8888。即使重新启动浏览器,应用程序2 URL也将重定向到https。之后,解决此问题的唯一方法是删除浏览器缓存并首先访问Application 2。

如何防止Application 2 URL自动重定向到https?

2 个答案:

答案 0 :(得分:0)

为应用程序1的tomcat web.xml文件添加了以下代码。这对我没有帮助。

<filter>
    <filter-name>httpHeaderSecurity</filter-name>
    <filter-class>org.apache.catalina.filters.HttpHeaderSecurityFilter</filter-class>
    <async-supported>true</async-supported>
    <init-param>
        <param-name>hstsEnabled</param-name>
        <param-value>false</param-value>
    </init-param>
    <init-param>
        <param-name>hstsMaxAgeSeconds</param-name>
        <param-value>0</param-value>
    </init-param>
</filter>

答案 1 :(得分:0)

此问题现已修复。在Spring引导应用程序的WebSecurityConfigurerAdapter中添加了代码。

http
.headers()
  .httpStrictTransportSecurity()
    .includeSubDomains(false)
    .maxAgeInSeconds(0);

规定 -raju

相关问题