Nginx配置Web支持HTTPS

开启并配置SSL

server {  
    listen       443;
    server_name  skyf.org www.skyf.org;
    ssl on;
    # CA下发的SSL证书
    ssl_certificate /etc/nginx/ssl_certificate/skyf_cer.crt;
    # 证书私钥
    ssl_certificate_key /etc/nginx/ssl_certificate/skyf_cer.key;

    ...code
}

所有HTTP请求转到HTTPS

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

配置完毕,重启nginx即可。