Nginx 配置SSL证书

1、下载Nginx 服务证书

2、配置nginx.conf

server {
  #SSL 访问端口号为 443
  listen 443 ssl; 
  #填写绑定证书的域名
  server_name cloud.tencent.com; 
  #证书文件名称
  #如果证书存放在nginx的conf文件夹下面,则可以直接为文件的名字;否则需要改文件所在的绝对路径如:/usr/local/cloud.tencent.com_bundle.crt   ssl_certificate cloud.tencent.com_bundle.crt;   #私钥文件名称   ssl_certificate_key cloud.tencent.com.key;   ssl_session_timeout 5m;   #请按照以下协议配置   ssl_protocols TLSv1.
2 TLSv1.3;   #请按照以下套件配置,配置加密套件,写法遵循 openssl 标准。   ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;   ssl_prefer_server_ciphers on;   location / {     #网站主页路径。此路径仅供参考,具体请您按照实际目录操作。     #例如,您的网站运行目录在/etc/www下,则填写/etc/www。     root html;     index index.html index.htm;   } }

3、Http自动跳转到Https

server {
    listen 80;
    #填写绑定证书的域名
    server_name cloud.tencent.com; 
    #把http的域名请求转成https
    return 301 https://$host$request_uri; 
}

 

posted @ 2022-05-01 17:11  编程人员老尧  阅读(16137)  评论(0编辑  收藏  举报