阿里云SSL证书申请及部署

落日映苍穹つ 2023-07-06 11:40 90阅读 0赞

阿里云SSL证书申请及部署

  • 证书申请
    • 申请通配符域名证书
    • 下载并部署证书
    • 安装完成并验证:

证书申请

这里以阿里云Symantec证书为例

申请通配符域名证书

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
20200218111603874.png

在xxx.cn 中配置location如下:
在这里插入图片描述
完整配置参考:

  1. server {
  2. listen 443 ssl;
  3. server_name xxx.cn;
  4. ssl_session_cache shared:SSL:1m;
  5. ssl_session_timeout 5m;
  6. ssl_ciphers HIGH:!aNULL:!MD5;
  7. ssl_prefer_server_ciphers on;
  8. set $mobile_rewrite do_not_perform;
  9. if ($http_user_agent ~* "(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino") {
  10. set $mobile_rewrite perform;
  11. }
  12. location / {
  13. if ($mobile_rewrite = perform) {
  14. root /usr/local/nginx/m/mobile;
  15. }
  16. if ($mobile_rewrite = do_not_perform) {
  17. root html;
  18. }
  19. }
  20. location /.well-known/pki-validation/fileauth.txt {
  21. root /usr/local/nginx/html;
  22. }
  23. }

把验证文件fileauth.txt上传到服务器上一步配置的目录中,本例的具体目录是:
/usr/local/nginx/html/.well-known/pki-validation

  1. E:\wy>scp fileauth.txt root@ip:/usr/local/nginx/html/.well-known/pki-validation
  2. root@ip's password:
  3. fileauth.txt 100% 64 1.7KB/s 00:00
  4. E:\wy>

查看文件:

  1. [root@izwz96u1ukkfo2k pki-validation]# ll
  2. total 4
  3. -rw-r--r-- 1 root root 64 Feb 18 11:00 fileauth.txt
  4. [root@izwz96u1ukkfo2k pki-validation]# pwd
  5. /usr/local/nginx/html/.well-known/pki-validation
  6. [root@izwz96u1ukkfo2k pki-validation]#

完成后重启nginx

  1. [root@izwz96u1ukkfo2k conf]# ../sbin/nginx -t
  2. nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
  3. nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
  4. [root@izwz96u1ukkfo2k conf]# ../sbin/nginx -s reload

然后验证,通过后提交。

在这里插入图片描述

坐等审核

在这里插入图片描述

下载并部署证书

审核通过后,下载证书,并选择nginx
在这里插入图片描述
在这里插入图片描述

上传证书到服务器

  1. E:\wy\ssl\3472164__xxx.cn_nginx>scp 3472164__xxx.cn.* root@ip:/usr/local/nginx/conf/ssl/www.xxx.cn
  2. root@ip's password:
  3. 3472164__xxx.cn.key 100% 1679 39.0KB/s 00:00
  4. 3472164__xxx.cn.pem 100% 3671 61.1KB/s 00:00
  5. E:\wy\ssl\3472164__xxx.cn_nginx>

配置nginx配置文件

  1. server {
  2. listen 80;
  3. server_name www.xxx.cn xxx.cn;
  4. return 301 https://$server_name$request_uri;
  5. set $mobile_rewrite do_not_perform;
  6. if ($http_user_agent ~* "(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino") {
  7. set $mobile_rewrite perform;
  8. }
  9. location / {
  10. if ($mobile_rewrite = perform) {
  11. root /usr/local/nginx/m/mobile;
  12. }
  13. if ($mobile_rewrite = do_not_perform) {
  14. root html;
  15. }
  16. }
  17. location /.well-known/pki-validation/fileauth.txt {
  18. root /usr/local/nginx/html;
  19. }
  20. location = /50x.html {
  21. root html;
  22. }
  23. error_page 500 502 503 504 /50x.html;
  24. }
  25. server {
  26. listen 443 ssl;
  27. server_name www.xxx.cn;
  28. ssl_session_cache shared:SSL:1m;
  29. ssl_certificate ./ssl/www.xxx.cn/3472164__xxx.cn.pem;
  30. ssl_certificate_key ./ssl/www.xxx.cn/3472164__xxx.cn.key;
  31. ssl_session_timeout 5m;
  32. ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
  33. ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
  34. ssl_prefer_server_ciphers on;
  35. set $mobile_rewrite do_not_perform;
  36. if ($http_user_agent ~* "(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino") {
  37. set $mobile_rewrite perform;
  38. }
  39. location / {
  40. if ($mobile_rewrite = perform) {
  41. root /usr/local/nginx/m/mobile;
  42. }
  43. if ($mobile_rewrite = do_not_perform) {
  44. root html;
  45. }
  46. }
  47. }

安装完成并验证:

部署前:

在这里插入图片描述

部署后

在这里插入图片描述

发表评论

表情:
评论列表 (有 0 条评论,90人围观)

还没有评论,来说两句吧...

相关阅读