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。

相关推荐
uoKent8 小时前
计网中的HTTP/HTTPS
网络协议·http·https
2501_9151063221 小时前
iOS数据采集技术详解:从性能监控到崩溃分析的全链路实践
android·ios·小程序·https·uni-app·iphone·webview
IPdodo_2 天前
2026年爬虫代理 IP 选择指南:从可用率、延迟到成本验收
网络协议·tcp/ip·scrapy·http·https·beautifulsoup·httpx
瓦格哈儿2 天前
删掉旧 SSL 证书会影响线上业务吗?风险点梳理
网络协议·https·ssl
美酒没故事°2 天前
https和tls有什么区别?
网络协议·http·https
Lsetea2 天前
Cloudflare报526 Invalid SSL certificate:源站证书与Nginx回源TLS排查
nginx·https·ssl证书·cloudflare·tls
Lsetea2 天前
SSL证书快过期怎么自动检查:用OpenSSL checkend做7天预警与线上证书验收
https·ssl证书·openssl·systemd·证书监控
MetaLite2 天前
HTTPS之外的响应加密-GCM序列化与处理器顺序
网络协议·http·https
Neighbor_OldY2 天前
云上证书过期与HTTPS安全治理实战:证书到期没人管、自动化续期与证书链排查
安全·https·自动化
美酒没故事°2 天前
是tls、https、waf
网络协议·http·https