欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 文旅 > 明星 > Web 升级 Https

Web 升级 Https

2024/10/24 4:47:38 来源:https://blog.csdn.net/code_nn/article/details/142920830  浏览:    关键词:Web 升级 Https

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

一、Web 应用升级

  1. 本地环境生成协议SSL/TLS 证书
keytool -genkeypair -keyalg RSA -keysize 2048 -storetype PKCS12 -keystore keystore.p12 -validity 3650
  1. 配置 Spring Boot 应用
server:port: 8080  # HTTPS 端口ssl:enabled: truekey-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 证书
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. 配置
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。

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com