• vue+springboot前后端分离项目中配置https


    首先前端,vue打包后生成了dist,使用tomcat作为静态服务器,在tomcat中使用jks格式配置https(不是jks可以不用往下看了):

    • 将文件拷贝到tomcat的conf目录,修改server.xml(注意修改jks和密码那里):
         <Connector port="443" protocol="org.apache.coyote.http11.Http11NioProtocol" maxThreads="150" SSLEnabled="true">
            <SSLHostConfig>
                <Certificate certificateKeystoreFile="conf/cdc.com.jks" certificateKeystorePassword="602tsfe" type="RSA"/>
            SSLHostConfig>
        Connector>
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 将下面加载web.xml最后面,不用修改任何东西:
    <login-config>
            
            <auth-method>CLIENT-CERTauth-method>
            <realm-name>Client Cert Users-only Arearealm-name>
        login-config>
        <security-constraint>
            
            <web-resource-collection >
                <web-resource-name >SSLweb-resource-name>
                <url-pattern>/*url-pattern>
            web-resource-collection>
            <user-data-constraint>
                <transport-guarantee>CONFIDENTIALtransport-guarantee>
            user-data-constraint>
        security-constraint>
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • springboot 配置https:
    • 首先将jks文件拷贝到classpath下(resources目录下)。
    • 然后在application.properties中添加:
    # 配置https:
    server.ssl.key-store=classpath:cd.com.jks
    server.ssl.key-store-password=60fe
    server.ssl.key-store-type=JKS
    
    • 1
    • 2
    • 3
    • 4
    • 然后配置http跳转https(请注意通过properties配置只能使用https或者http,不能同时使用https和http):
      算了不配了,能用就行。
  • 相关阅读:
    component 动态组件的用法
    Dockcer上传hub和配置国内镜像源
    JS高级 之 Promise 详解
    yolo各模块详解
    12.netty中tcp粘包拆包问题及解决方法
    大数据实训2 - 法律咨询数据分析和服务推荐
    MySQL中索引的基本知识
    01.Swagger配置
    Spring Cloud Gateway编码实现任意地址跳转
    linux基础(2)
  • 原文地址:https://blog.csdn.net/ruankun521/article/details/134450563