Web 升级 Https

Web 应用协议从 http 升级到 https。

一、Web 应用升级

  1. 本地环境生成协议SSL/TLS 证书
bash 复制代码
keytool -genkeypair -keyalg RSA -keysize 2048 -storetype PKCS12 -keystore keystore.p12 -validity 3650
  1. 配置 Spring Boot 应用
yaml 复制代码
server:
  port: 8080  # HTTPS 端口
  ssl:
    enabled: true
    key-store: classpath:keystore.p12  # keystore 文件路径,通常放在 resources 文件夹中
    key-store-password: your_password  # keystore 密码
    key-store-type: PKCS12  # keystore 类型
    key-alias: tomcat  # keystore 中的 key 别名

二、nginx

  1. 获取 SSL/TLS 证书
bash 复制代码
openssl genpkey -algorithm RSA -out server.key
openssl req -new -key server.key -out server.csr
openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt    
  1. 配置
xml 复制代码
server {
    listen 443 ssl;
    server_name example.com;
    
    ssl_certificate /path/to/certificate.crt;
    ssl_certificate_key /path/to/private.key;
    
    # 其他 HTTPS 配置...
}

三、常见问题

  1. HTTPS 可以访问 HTTP 吗?

HTTPS 页面本身不能直接访问 HTTP 页面,浏览器会阻止这种混合内容(Mixed Content)的请求。

  1. HTTP 可以访问 HTTPS 吗?

HTTP 页面可以重定向到 HTTPS 页面。这是实现 HTTP 到 HTTPS 的迁移过程中常见的做法,通过 301 重定向,自动将 HTTP 请求转向 HTTPS。

相关推荐
2501_9159184131 分钟前
如何解析iOS崩溃日志:从获取到符号化分析
android·ios·小程序·https·uni-app·iphone·webview
BUG_MeDe16 小时前
openssl 生成自签名证书步骤
服务器·https·ssl·数字证书
m0_495562781 天前
https的原理
网络协议·http·https
游戏开发爱好者81 天前
iPhone重启日志深度解析与故障代码诊断
android·ios·小程序·https·uni-app·iphone·webview
2301_803554522 天前
https
网络协议·http·https
心一信息2 天前
http与https的详细介绍
网络协议·http·https
谢尔登2 天前
HTTPS 究竟比 HTTP 好在哪?
http·https·ssl
00后程序员张3 天前
接口调试从入门到精通,Fiddler抓包工具、代理配置与HTTPS抓包实战技巧
前端·ios·小程序·https·fiddler·uni-app·webview
游戏开发爱好者84 天前
iOS IPA 上传工具全面解析,从 Transporter 到开心上架(Appuploader)命令行的高效上架实践
android·ios·小程序·https·uni-app·iphone·webview
IUGEI4 天前
深入解析HTTP长连接原理
java·网络·后端·网络协议·tcp/ip·http·https