0
点赞
收藏
分享

微信扫一扫

06. 截断文本 && 选择任何链接 && :root 和 html 有什么区别

陈情雅雅 2024-07-24 阅读 5

Nginx配置ssl证书(https)

方式一:直接加(不使用重定向)

不使用default关键字

server {
     #为8092端口用SSL/TLS协议进行加密(就是改为https协议)
     listen 8092 ssl; 
     #请填写绑定证书的域名 (或者使用 _ 作为捕获所有)
     server_name cloud.tencent.com; 
     #请填写证书文件的相对路径或绝对路径
     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 和配置https没有关联,是前端包的位置
     location / {
         #网站主页路径。此路径仅供参考,具体请您按照实际目录操作。
         #例如,您的网站主页在 Nginx 服务器的 /etc/www 目录下,则请修改 root 后面的 html 为 /etc/www。
         root html; 
         index  index.html index.htm;
     }
 }

使用default关键字

server {
     #为8092端口用SSL/TLS协议进行加密(就是改为https协议)
     listen 8092 default ssl; 
     #当使用了default ssl 后变为_ ;也直接可以忽略不写
     # server_name _; 
     #请填写证书文件的相对路径或绝对路径
     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 和配置https没有关联,是前端包的位置
     location / {
         #网站主页路径。此路径仅供参考,具体请您按照实际目录操作。
         #例如,您的网站主页在 Nginx 服务器的 /etc/www 目录下,则请修改 root 后面的 html 为 /etc/www。
         root html; 
         index  index.html index.htm;
     }
 }

方式二:使用重定向 (用到了443端口)

server {
 #SSL 默认访问端口号为 443
 listen 443 ssl;
 #请填写绑定证书的域名
 server_name cloud.tencent.com; 
 #请填写证书文件的相对路径或绝对路径
 ssl_certificate  cloud.tencent.com_bundle.crt; 
 #请填写私钥文件的相对路径或绝对路径
 ssl_certificate_key cloud.tencent.com.key; 
 ssl_session_timeout 5m;
 #请按照以下套件配置,配置加密套件,写法遵循 openssl 标准。
 ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
 #请按照以下协议配置
 ssl_protocols TLSv1.2 TLSv1.3;
 ssl_prefer_server_ciphers on;
 location / {
   #网站主页路径。此路径仅供参考,具体请您按照实际目录操作。 
   #例如,您的网站主页在 Nginx 服务器的 /etc/www 目录下,则请修改 root 后面的 html 为 /etc/www。
   root html;
   index index.html index.htm;
 }
}
server {
 listen 80;
 #请填写绑定证书的域名
 server_name cloud.tencent.com; 
 #把http的域名请求转成https(https不指定端口的前提下默认是443)
 return 301 https://$host$request_uri; 
}

如果想变成从 http://cloud.tencent.com:8089 自动重定向到 https://cloud.tencent.com:8089

就使用上面的 方式一直接加 即可

举报

相关推荐

0 条评论