#配置1http跳转https配置
server {
listen 80;
server_name xxx.com;#域名
rewrite ^(.*)$ https://$host$1 permanent;
}
#配置2https 443端口
server {
#listen 80;#去掉#号开启同时监听HTTP和HTTPS,根据访问协议自动调整(去掉配置1)
listen 443 ssl;
server_name xxx.com;#域名
root /project;#项目目录
#注意这里没有 ssl on
ssl_certificate /xxx.pem; # 指定证书的位置,绝对路径
ssl_certificate_key /xxx.key; # 绝对路径,同上
ssl_session_timeout 5m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
location / {
index index.html index.htm index.php;
try_files $uri $uri/ /index.php?$args;
}
location ~ .php {
root /project;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi.conf;
#fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
#include fastcgi_params;
#set $path_info "";
#set $real_script_name $fastcgi_script_name;
#if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") {
# set $real_script_name $1;
# set $path_info $2;
#}
#fastcgi_param SCRIPT_FILENAME $document_root$real_script_name;
#fastcgi_param SCRIPT_NAME $real_script_name;
#fastcgi_param PATH_INFO $path_info;
}
}