+
 新版

Tomcat配置https、访问http自动跳转至https

豫华商 发布于 2021/03/29 15:41
阅读 222
收藏 0

公司买了一个SSL证书,将网站配置成了https访问的形式,可是http访问却访问不到了,应用服务器采用的是tomcat,请问怎么配置可以实现访问http时自动跳转到https的形式呢?

加载中
0
中控易动
中控易动

试试这个

tomcat8
①conf/server.xml

 <Connector port="80" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="443" />

②之后在conf/web.xml的最下面</web-app>前加上

<login-config>
        <!-- Authorization setting for SSL -->
        <auth-method>CLIENT-CERT</auth-method>
        <realm-name>Client Cert Users-only Area</realm-name>
    </login-config>
    <security-constraint>
        <!-- Authorization setting for SSL -->
        <web-resource-collection >
            <web-resource-name >SSL</web-resource-name>
            <url-pattern>/*</url-pattern>
        </web-resource-collection>
        <user-data-constraint>
            <transport-guarantee>CONFIDENTIAL</transport-guarantee>
        </user-data-constraint>
    </security-constraint>

③重启tomcat

豫华商
豫华商
感谢帮助,我基本是这么配置的,应该是硬件上封死端口导致我这儿没访问通的。
0
戰五渣
戰五渣

ngnix可以配置

豫华商
豫华商
没有用Nginx,tomcat的配置方案网上试了几种不好使。
OSCHINA
登录后可查看更多优质内容
返回顶部
顶部