https小记

背景:现在不用https很难愉快的进行开发 ,微信全家桶发,react native等都需要我们接口为https.....接下分享下我的https历程。

这里我用的证书是阿里云的CA证书


1.下载证书
2.将证书发到服务器
3.修改nginx配置

server {  
    listen  80;
    server_name hello.yinjikai.top
      
    rewrite ^(.*)$  https://$host$1 permanent;  
}

server {
    listen 443 ssl;
    server_name hello.yinjikai.top;
    index index.html index.htm;
    access_log  /var/log/nginx/docs.log  main;
    ssl on;
    ssl_certificate /etc/ssl/docs.20150509.cn.crt;
    ssl_certificate_key  /etc/ssl/docs.20150509.cn.key;
    error_page 404 /404.html;
    location / {
        root /var/www/html/docs;
    }
}

4.重启nginx服务

  1. 站点前面出现了安全的小绿锁


    image.png
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容