server {
listen 80;
server_name www.yourdomain.com;
rewrite ^(.*) https://$server_name$1 permanent;
}
server {
listen 443 ssl;
server_name www.yourdomain.com;
root /home/www;
ssl_certificate /path/to/certs/xxxxxx.crt;
ssl_certificate_key /path/to/certs/xxxxxx.pem;
}
server_name www.yourdomain.com; 解析到本机IP的域名
root /home/www; 项目根目录
ssl_certificate /path/to/certs/xxxxxx.crt; 证书文件,也有可能是cer后缀
ssl_certificate_key /path/to/certs/xxxxxx.pem; 证书对应的私钥文件