$scheme 是当前访问的协议,使用它可以将 http 跳转到 https;



if ($scheme = http) {
    rewrite ^(.*)$ https://$host$1 permanent;
}