nginx配置https

1、申请ssl证书
ssl证书是收费的,当然对于个人而言用免费版的就好了,免费版可在:https://freessl.cn/申请
2、下载并上传你申请的证书到服务器
3、配置nginx,并将http跳转到https
[code]
server {
listen 80;
server_name xxx.com www.xxx.com;
rewrite ^(.*)$ https://$host$1 permanent;
}

server {
#listen 80;
listen 443;
server_name xxx.com www.xxx.com;
ssl on;
ssl_certificate /home/wwwroot/nginx/conf/full_chain.pem;
ssl_certificate_key /home/wwwroot/nginx/conf/private.key;
access_log /home/wwwroot/nginx/logs/xxx.log;

location / {
root /home/wwwroot/www/xxx/;
index index.php index.html index.htm;
}
location ~ \.php$ {
root /home/wwwroot/www/xxx/;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
[/code]