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):
    算了不配了,能用就行。
相关推荐
txxzjmzlh2 小时前
SpringBoot 统⼀功能处理
java·spring boot·后端
FlyWIHTSKY6 小时前
vue2和vue3有什么区别,用法上有哪些区别
前端·javascript·vue.js
秋天的怀念_David9 小时前
算法一千零一夜 · 第二十六夜 协议的母语
java·spring boot·算法
余槐i10 小时前
MySQL 8.0 联合索引走错:为什么加了索引查询反而从 200ms 变成 8s
java·spring boot·mysql·docker·性能优化
ruanno_top11 小时前
能点,但 Tab 不到:两个组件把「可操作」做了一半
vue.js
爱吃烧烤的技术渣11 小时前
别再手写 CRUD 了:我把 Element Plus 的工作量压缩成一份列 schema
前端·vue.js
徐小夕14 小时前
万字长文!DeepSeek Super-agent × 企业知识库架构深度拆解与落地实践
前端·vue.js·github
nice_lcj52015 小时前
【从零理解 Spring AI · 03】Spring AI 在 Spring 生态里的位置
java·spring boot·大模型·spring ai·ai应用开发
AI源码1 天前
旅游推荐管理系统
spring boot
Lsetea1 天前
Docker更新SSL证书后容器仍读旧文件:单文件挂载与目录挂载排查
运维·nginx·docker·https·ssl证书