免费证书加密https

生成免费证书

GIthub地址:[acme]: https://github.com/Neilpang/acme.sh /(免费证书github地址)

生成方法:
curl https://get.acme.sh | SH
执行完后,脚本位置在~/.acme.sh/下
acme.sh --issue --nginx -d example.com -d www.example.com -d cp.example.com
[上面命令是github给出的,我在服务器上执行的是下面的命令行] ` sh ~/.acme.sh/acme.sh –issue –nginx -d myucloud.com -d www.myucloud.com –force`
执行完之后,屏幕上会显示生成证书的位置

配置nginx

  • 默认是https访问,当访问80端口时,指向https
  • 在nginx/conf.d/下添加conf,只需要指定证书ssl_certificate/ssl_certificate_key位置,将www.xx.com替换成你的域名即可
server {
    listen  443 ssl;
    ssl_certificate      ./ssl/youdomain.cer;
    ssl_certificate_key  ./ssl/youdomain.key;
    ssl_session_timeout  5m;
    ssl_protocols       TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers         HIGH:!aNULL:!MD5;
    server_name  www.xx.com;
    location / {
        root   /opt/html;
        index  index.html index.htm index.php;
    }
}

server {
    listen 80;
    server_name  www.xx.com;
    rewrite ^(.*)$ https://${server_name}$1 permanent;
}

打赏一个呗

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码支持
扫码打赏,你说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦