server {
listen 80;
listen 443 ssl; #监听ssl 443端口
server_name www.demo.com;</code>
if ($server_port !~ 443) {
rewrite ^(/.*)$ https://$host$1 permanent;
}
ssl_certificate xxx.pem; #证书文件
ssl_certificate_key xxx.key; #密钥文件
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; #协议使用配置
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE; #加密套件
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;
error_page 497 https://$host$request_uri;
root /www/wwwroot/wordpress;
client_max_body_size 5M;
location / {
index index.php index.html;
}
location ~ \.php$ {
fastcgi_pass unix:xxx.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
access_log logs/www.demo.com.access.log;
error_log logs/www.demo.com.error.log;
}