• Nginx https ssl配置
server {
    listen 443 ssl;   #SSL协议访问端口号为443。此处如未添加ssl,可能会造成Nginx无法启动。
    server_name www.wuloves.com;  #将localhost修改为您证书绑定的域名,例如:www.example.com。
    root /web/www.wuloves.com;
    index index.php index.html index.htm;
    ssl_certificate /key/www.wuloves.com/www.wuloves.com.pem;   #将domain name.pem替换成您证书的文件名。
    ssl_certificate_key /key/www.wuloves.com/www.wuloves.com.key;   #将domain name.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 / {
#        try_files $uri $uri/ /index.php?$query_string;
#    }
    # 将blog目录下的路由重写到blog/index.php

    location /blog/ {
        if (!-e $request_filename) {
            rewrite ^/ /blog/index.php last;
        }
    }

    location ~ \.php {
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_split_path_info  ^(.+\.php)(/.*)$;
        fastcgi_param  PATH_INFO $fastcgi_path_info;
        include        fastcgi.conf;
        if (!-e $request_filename) {
            rewrite ^/ /blog/index.php last;
        }
    }
        access_log /web/logs/www.wuloves.com.success.ssl.log;
        error_log  /web/logs/www.wuloves.com.error.ssl.log;
} 
  • Nginx 强制https访问
server {
    listen       80;
    server_name  www.wuloves.com;
    rewrite ^(.*)$  https://$host$1 permanent;  
    access_log /dev/null;
    error_log  /dev/null;
}

标签: none

添加新评论