nginx配置https

server {
    listen          80;
    listen          443 ssl;
    ssl             on;
    server_name www.hcnbjf.com hcnbjf.com;
    ssl_protocols TLSv1.2 TLSv1.1 TLSv1;
    ssl_certificate /etc/ssl/hcnbjf.crt;                                #证书位置
    ssl_certificate_key /etc/ssl/hcnbjf.key;                            #key位置
    ssl_ciphers         HIGH:!aNULL:!MD5;
    ssl_prefer_server_ciphers on;
    if ($server_port = 80) {
    rewrite ^(.*)$ https://$host$1 permanent;
    }       
    index           index.html index.htm index.php;
    root            /home/www/jf;

    if ( $host ~* ^(?!www\.) ) {
     rewrite .* $scheme://www.$host$request_uri permanent;
    }

    if (!-e $request_filename) {
            rewrite  ^(.*)$  /index.php?s=$1  last;
            break;
    }

    location / {
            try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ \.php$ {
            include fastcgi_params;
            fastcgi_pass unix:/var/run/php-fpm.socket;
    }     
}

你可能感兴趣的:(nginx配置https)