现在腾讯提供免费的一年证书,地址:https://console.qcloud.com/ssl

nginx重定向 http 自动跳转 https

server
    {
        listen 80;
        server_name blog.luoli.net;
        index index.html index.htm index.php;
        rewrite ^/(.*)$ https://blog.luoli.net/$1 permanent;  //第一种
        return 301 https://www.baidu.com$request_uri;  //第二种
    }

配置ssl证书:

server
    {
        listen 443;
        #listen [::]:80;
        server_name blog.luoli.net;
        index index.html index.htm index.php;
        root  /www;

        ssl on;
        ssl_certificate /ssl/blog.luoli.net_cert.crt;
        ssl_certificate_key /ssl/blog.luoli.net.key;

        include typecho.conf;
        #error_page   404   /404.html;
        include enable-php-pathinfo.conf;

        location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
        {
            expires      30d;
        }

        location ~ .*\.(js|css)?$
        {
            expires      12h;
        }

        location ~ /\.
        {
            deny all;
        }

        access_log off;
    }

安装完成。腾讯免费SSL证书+LNMP环境演示:https://blog.luoli.net/