当前位置:网站首页 / 建站 / 正文

申请阿里云免费SSL证书并配置NGINX

时间:2017年03月15日 | 作者 : liuhui | 分类 : 建站 | 浏览: 7097次 | 评论 1

阿里云限量代金券 | 此广告位出租25元/月

越来越多的网站用上了https协议,https可以保护网站传输的数据安全,对搜索引擎也友好,本站现在也用上https了,分享一下我的配置经验:

1.jpg

一、进入 https://common-buy.aliyun.com/?commodityCode=cas#/buy ,选择购买赛门铁克的免费 DV 证书。 

1.jpg

二、购买之后,象征性的走一遍付费流程,然后就是补全证书信息了。 

2.jpg

三、等待审核通过下载证书然后加到nginx虚拟主机配置里,我的配置文件:

server {

listen 80;

server_name diannaobos.com www.diannaobos.com;

rewrite ^(.*) https://$server_name$1 permanent;

}

server

    {

        listen 443;

        #listen [::]:80;

          ssl on;

        server_name diannaobos.com www.diannaobos.com;

        index index.html index.htm index.php default.html default.htm default.php;

        root  /home/wwwroot/www.diannaobos.com;

     ssl_certificate   /usr/local/nginx/ssl/214045388450580.pem;

    ssl_certificate_key  /usr/local/nginx/ssl/214045388450580.key;

    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;


        include diannaobos.conf;

        #error_page   404   /404.html;

        include enable-php.conf;


        location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$

        {

            expires      30d;

        }


        location ~ .*\.(js|css)?$

        {

            expires      12h;

        }


        location ~ /\.

        {

            deny all;

        }


        access_log  /home/wwwlogs/www.diannaobos.com.log;

    }

四、保存配置后先执行如下命令,测试配置是否正确

/usr/local/nginx/sbin/nginx -t

如果正确无误会显示如下

nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok

nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful

确认无误后重载nginx,让配置生效

lnmp reload

如果没有错误,刷新一下页面就能看到https绿色的小锁了!


参考链接:https://bbs.aliyun.com/read/298246.html

http://zhoumo123.cn/nginx/2368.html


推荐您阅读更多有关于“”的文章

猜你喜欢

网站分类
关注电脑博士
友情链接

分享:

支付宝

微信