当前位置: 首页 > news >正文

SpringBoot + Vue2项目打包部署到服务器后,使用Nginx配置SSL证书,配置访问HTTP协议转HTTPS协议

配置nginx.conf文件,这个文件一般在/etc/nginx/...中,由于每个人的体质不一样,也有可能在别的路径里,自己找找...

# 配置工作进程的最大连接数
events {worker_connections 1024;
}# 配置HTTP服务
http {# 导入mime.types配置文件include mime.types;# 设置默认的MIME类型为application/octet-streamdefault_type application/octet-stream;# 配置HTTP协议,如果访问的端口为80,即HTTP协议,则跳转到HTTPS协议server {# 监听端口80listen 80;# 配置服务器名称server_name www.feituplan.com feituplan.com;# 重定向到HTTPS协议rewrite ^(.*)$ https://$host$1 permanent;}# 配置HTTPS协议server {# 监听默认的HTTPS端口listen 443 ssl;# 配置服务器名称server_name feituplan.com;# 配置SSL证书路径,如下图ssl_certificate cert/www.feituplan.com.pem;# 配置SSL证书的私钥路径,如下图ssl_certificate_key cert/www.feituplan.com.key;# 配置SSL会话缓存ssl_session_cache shared:SSL:1m;# 配置SSL会话超时时间ssl_session_timeout 5m;# 设置服务器端密码套件优先ssl_prefer_server_ciphers on;# 设置默认的索引文件index index.html;# Vue项目存放路径root /www/wwwroot/vue/html;location / {# 尝试匹配URL路径,如果找不到对应的文件,则重定向到index.htmltry_files $uri $uri/ /index.html;}#当请求中包含"/map"路径时,将请求转发到"https://feituplan.com:8088"这个地址上location /map {# 反向代理到https://feituplan.com:8088proxy_pass https://feituplan.com:8088;# 添加反向代理的请求头,并隐藏响应头中的X-Powered-By字段proxy_set_header Host $http_host;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_hide_header X-Powered-By;}#当请求中包含"/image"路径时,将请求转发到"https://feituplan.com:8088"这个地址上location /image {# 反向代理到https://feituplan.com:8088proxy_pass https://feituplan.com:8088;# 添加反向代理的请求头,并隐藏响应头中的X-Powered-By字段proxy_set_header Host $http_host;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_hide_header X-Powered-By;}#当请求中包含"/feedback"路径时,将请求转发到"https://feituplan.com:8088"这个地址上location /feedback {# 反向代理到https://feituplan.com:8088proxy_pass https://feituplan.com:8088;# 添加反向代理的请求头,并隐藏响应头中的X-Powered-By字段proxy_set_header Host $http_host;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_hide_header X-Powered-By;}}
}

证书存放位置,可自定义存放位置
在这里插入图片描述
两个文件

在这里插入图片描述
后端配置
把.pfx拷贝到resource下,然后配置一下yml

  ssl:key-store: www.feituplan.com.pfx # pfk存放路径key-store-type: PKCS12  # tomcat服务器类型默认key-store-password: htg72rfy # txt密码粘贴即可

在这里插入图片描述

http://www.lryc.cn/news/217992.html

相关文章:

  • HTML 表格
  • AIGC(生成式AI)试用 10 -- 安全性问题
  • STM32循迹小车原理介绍和代码示例
  • Nginx 配置详细讲解
  • gdb 日志记录不显示到屏幕的方法(gdb13最新版)
  • JAVA智慧工地管理系统源码基于微服务
  • 学习笔记三十四:Ingress和 Ingress Controller概述
  • Webpack的Tree Shaking。它的作用是什么?
  • 研发效能DevOps: Git安装
  • ZZ038 物联网应用与服务赛题第D套
  • 基于STM32设计的室内环境监测系统(华为云IOT)_2023
  • UE5C++学习(一)--- 增强输入系统
  • 好物周刊#29:项目管理软件
  • 玻色量子“天工量子大脑”亮相中关村论坛,大放异彩
  • 使用Gorm进行高级查询
  • 基于梯度算法的无人机航迹规划-附代码
  • 【工具】【IDE】Qt Creator社区版
  • 王道p18 6.从有序顺序表中删除所有其值重复的元素,使表中所有元素的值均不同(c语言代码实现)
  • Python入门:6个好用的Python代码,快来收藏!
  • Linux常用指令(二)——文件管理
  • AI开源 - LangChain UI 之 Flowise
  • java的集合类中哪些可以添加不同类型数据,哪些不可以?
  • 基于51单片机的烟雾和温湿度检测控制系统仿真(智能防火系统,火灾报警灭火系统)
  • 【多线程】静态代理
  • 线性代数 第二章 矩阵
  • vue实现自定义字体
  • Selenium安装WebDriver Chrome驱动(含 116/117/118/119/120/)
  • springboot的安全机制
  • 学习c++的第四天
  • BIOS开发笔记 – 显示