如何在没有重定向的情况下在Tomcat中启用HTTP和HTTPS?

Sta*_*rry 3 tomcat

我正在配置Tomcat以支持HTTP(在端口8080上)和HTTPS(端口8443).在server.xml中,如果我这样配置:

    <Connector port="8080" protocol="HTTP/1.1"
           connectionTimeout="20000"
           URIEncoding="UTF-8" 
           redirectPort="8443" />

    <Connector port="8443" protocol="HTTP/1.1" 
           SSLEnabled="true"
           scheme="https" 
           secure="true"
           Server=""
           keystoreFile="conf/.keystore"
           keystorePass="password"
           maxThreads="150"
           maxSpareThreads="75"
           minSpareThreads="25" 
           clientAuth="false" sslProtocol="TLS" 
           URIEncoding="UTF-8"
           />
Run Code Online (Sandbox Code Playgroud)

http:// SERVER_IP:8080的所有访问都将定向到https:// SERVER_IP:8443.如何禁用重定向,并允许http和https访问?

我试图删除redirectPort="8443",但它不起作用.

Sta*_*rry 6

在@pedrofb的帮助下,我找到了解决方案:除了修改server.xml文件外,编辑web.xml文件,如:

<security-constraint>
    <web-resource-collection>
    <web-resource-name>Support Both HTTP and HTTPS
    </web-resource-name>
    <url-pattern>/*</url-pattern>
    </web-resource-collection>
    <user-data-constraint>
      <!-- <transport-guarantee>CONFIDENTIAL</transport-guarantee> -->
    </user-data-constraint>
</security-constraint>
Run Code Online (Sandbox Code Playgroud)

确保<transport-guarantee>CONFIDENTIAL</transport-guarantee>被注释,否则它只允许HTTPS访问.