加入收藏 | 设为首页 | 会员中心 | 我要投稿 辽源站长网 (https://www.0437zz.com/)- 云专线、云连接、智能数据、边缘计算、数据安全!
当前位置: 首页 > 服务器 > 搭建环境 > Linux > 正文

阿里云免费购买SSL证书,nginx无缝升级https

发布时间:2021-01-19 01:01:01 所属栏目:Linux 来源:网络整理
导读:最近在升级交流学习社区,觉得有必要升级成https.以下是自己在升级中记录。 以下包括以下部分: 一、阿里云免费购买SSL证书 1、自己在阿里云申请了免费的,然后自己支付0元,购买了SSL证书 2、我选择DNS验证 3、在SSL证书中,下载cert证书,然后放到nginx服

最近在升级交流学习社区,觉得有必要升级成https.以下是自己在升级中记录。

以下包括以下部分:

一、阿里云免费购买SSL证书

1、自己在阿里云申请了免费的,然后自己支付0元,购买了SSL证书

2、我选择DNS验证

3、在SSL证书中,下载cert证书,然后放到nginx服务器上

二、nginx无缝升级https

4、查看nginx是否支持ssl

5、配置ssl模块

6、重新编译一下

7、因为这次是升级nginx,所以不需要执行 make install,首先备份原nginx执行脚本

8、把新编译的nginx执行脚本拷贝到相应的目录下:’

9、最后进行平滑升级

10、再次检查nginx是否有https模块

11、展示一下https网站站点,

附注1:nginx配置SSL报错问题,ssl on报错

附注2:nginx的https服务配置

1、自己在阿里云申请了免费的,然后自己支付0元,购买了SSL证书

阿里云免费购买SSL证书,nginx无缝升级https

2、我选择DNS验证,因为域名是自己的。

阿里云免费购买SSL证书,nginx无缝升级https

3、在SSL证书中,下载cert证书,然后放到nginx服务器上

阿里云免费购买SSL证书,nginx无缝升级https

4、查看nginx是否支持ssl:

./nginx -V

阿里云免费购买SSL证书,nginx无缝升级https

查看 configure arguments 信息中是否包含 -with-http_ssl_module 字样

5、配置ssl模块

找到之前安装 Nginx 时的解压目录,配置ssl模块:

./configure ---http_ssl_module

阿里云免费购买SSL证书,nginx无缝升级https

6、重新编译一下

在解压目录执行make

make

阿里云免费购买SSL证书,nginx无缝升级https

?7、因为这次是升级nginx,所以不需要执行 make install,首先备份原nginx执行脚本:

mv /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.old

阿里云免费购买SSL证书,nginx无缝升级https

?8、把新编译的nginx执行脚本拷贝到相应的目录下:

cd objscp nginx /usr/local/nginx/sbin/

阿里云免费购买SSL证书,nginx无缝升级https

阿里云免费购买SSL证书,nginx无缝升级https

9、最后进行平滑升级

阿里云免费购买SSL证书,nginx无缝升级https

10、再次检查nginx是否有https模块

?

阿里云免费购买SSL证书,nginx无缝升级https

11、展示一下https网站站点,

阿里云免费购买SSL证书,nginx无缝升级https

附注1:nginx配置SSL报错问题,ssl on报错

启动报错(错误信息:nginx: [emerg] the "ssl" parameter ngx_http_ssl_module /home/soft/nginx/conf/nginx.conf:)

需要配置模块ssl模块?--with-http_ssl_modul,请查看本文的第二部分:2、配置ssl模块

附注2:nginx的https服务配置

server </span><span style="color: #008000;"&gt;{</span><span style="color: #008000;"&gt; listen 443; server_name www.mwcxs.top; ssl on; root /home/nodejs/liblog/www; index index.js index.html index.htm; ssl_certificate /usr/local/nginx/cert/15420110408020120565539868.crt; ssl_certificate_key /usr/local/nginx/cert/15420110408020120565539868.key; ssl_session_cache shared:SSL:1m; ssl_session_timeout 5m; ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_prefer_server_ciphers on; if ( -f $request_filename/index.html ){ rewrite (.</span><span style="color: #008000;"&gt;*)</span> $<span style="color: #800080;"&gt;1</span>/index.html <span style="color: #0000ff;"&gt;break</span><span style="color: #000000;"&gt;; } </span><span style="color: #0000ff;"&gt;if</span> ( !-f $request_filename )<span style="color: #008000;"&gt;{</span><span style="color: #008000;"&gt; rewrite (.</span><span style="color: #008000;"&gt;*)</span> /<span style="color: #000000;"&gt;index.js; } location </span>/ <span style="color: #008000;"&gt;{</span><span style="color: #008000;"&gt; proxy_http_version 1.1; proxy_set_header Connection ""; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_set_header X-NginX-Proxy true; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_pass http://learning_community_node$request_uri; proxy_redirect off; </span><span style="color: #008000;"&gt;}</span><span style="color: #000000;"&gt; location </span>= /production.js <span style="color: #008000;"&gt;{</span><span style="color: #008000;"&gt; deny all; </span><span style="color: #008000;"&gt;}</span><span style="color: #000000;"&gt; location </span>= /testing.js <span style="color: #008000;"&gt;{</span><span style="color: #008000;"&gt; deny all; </span><span style="color: #008000;"&gt;}</span><span style="color: #000000;"&gt; location ~ </span>/static/ <span style="color: #008000;"&gt;{</span><span style="color: #008000;"&gt; etag on; expires max; </span><span style="color: #008000;"&gt;}</span><span style="color: #000000;"&gt; } server </span><span style="color: #008000;"&gt;{</span><span style="color: #008000;"&gt; listen 80; server_name www.mwcxs.top mwcxs.top; <span style="color: #ff0000;"&gt;<strong>return 301 https://$server_name$request_uri; </strong></span></span><span style="color: #008000;"&gt;}</span></pre>
注:return 301 https://$server_name$request_uri;用来把http转换成https。欢迎关注:,欢迎fork和start

(编辑:辽源站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读