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。

相关推荐
程序员夏洛4 小时前
TCP 是用来解决什么问题?
java·网络协议·http·https
青瓦梦滋1 天前
【在线五子棋对战】游戏匹配模块
网络·c++·网络协议·http·https
Lsetea2 天前
curl设置SSL_CERT_FILE仍报60:CURL_CA_BUNDLE与CA路径优先级排查
linux·https·ssl证书·openssl·curl
2501_915921432 天前
iOS应用从开发到上架App Store的完整步骤详解
android·ios·小程序·https·uni-app·iphone·webview
上海云盾-小余2 天前
自定义端口 HTTPS 部署:高防接入遇到的问题与调优方案
网络协议·http·https
是个西兰花3 天前
https 协议原理
网络协议·http·https
长按助力退休3 天前
HTTPS加密原理详解,TLS握手到底在干什么
https
0+1113 天前
Linux --HTTPS协议原理
网络协议·http·https
北城笑笑3 天前
Server 18 ,Nginx 双服务器 HTTP转HTTPS 代理实战( HTTP 地址换 HTTPS 域名 )
运维·服务器·前端·后端·nginx·http·https
Lsetea3 天前
OpenSSL报certificate rejected:error 28与CA辅助信任属性排查
linux·https·ssl证书·openssl·证书链