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

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

  • 将文件拷贝到tomcat的conf目录,修改server.xml(注意修改jks和密码那里):
xml 复制代码
     <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>
  • 将下面加载web.xml最后面,不用修改任何东西:
xml 复制代码
<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>
  • springboot 配置https:
  • 首先将jks文件拷贝到classpath下(resources目录下)。
  • 然后在application.properties中添加:
xml 复制代码
# 配置https:
server.ssl.key-store=classpath:cd.com.jks
server.ssl.key-store-password=60fe
server.ssl.key-store-type=JKS
  • 然后配置http跳转https(请注意通过properties配置只能使用https或者http,不能同时使用https和http):
    算了不配了,能用就行。
相关推荐
前端Hardy2 小时前
干掉 Virtual DOM?尤雨溪开始"强推" Vapor Mode?
vue.js·vue-router
初次攀爬者2 小时前
RocketMQ在Spring Boot上的基础使用
java·spring boot·rocketmq
花花无缺2 小时前
搞懂@Autowired 与@Resuorce
java·spring boot·后端
Mr_li2 小时前
给 Vue 开发者的 uni-app 快速指南
vue.js·uni-app
Derek_Smart4 小时前
从一次 OOM 事故说起:打造生产级的 JVM 健康检查组件
java·jvm·spring boot
icebreaker5 小时前
Weapp-vite:原生模式之外,多一种 Vue SFC 选择
前端·vue.js·微信小程序
icebreaker5 小时前
重走 Vue 长征路 Weapp-vite:编译链路与 Wevu 运行时原理拆解
前端·vue.js·微信小程序
wuhen_n5 小时前
代码生成:从AST到render函数
前端·javascript·vue.js
wuhen_n6 小时前
AST转换:静态提升与补丁标志
前端·javascript·vue.js