方式一.CDN+https(CDN给的便宜货,加载反而慢了,弃用)

使用阿里云CDN自带的https可以减少nginx配置工作,1年1-2元钱的总体费用

https://cdn.console.aliyun.com/overview

域名管理

开启https,使用免费https证书,自动续

开启http->https跳转


方式二.nginx自己配(选用)

在阿里云上面申请免费ssl证书后下载到本地,nginx配置如下

    server {
        listen 443 ssl;
        ssl_certificate /var/ijilu_cn/ssl/ijilu.cn.crt;
        ssl_certificate_key	/var/ijilu_cn/ssl/ijilu.cn.key;
        server_name  ijilu.cn;
        location / {
            set $ver "20231107";
            root   /var/ijilu_cn/links;
            ssi on;
            index  index.html index.htm;
        }
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
        root   /usr/share/nginx/html;
        }
    }

方式三.node层配置

    const enforceHttps = require('/var/ijilu_cn/node_modules/koa-sslify');
    const options = require('/var/ijilu_cn/db/certificate');
    // Force HTTPS on all page
    app.use(enforceHttps());
    https.createServer(options, app.callback()).listen(100);