Nginx HTTPS配置

现在越来越多的网站使用HTTPS协议,使用该协议需要SSL证书。

这里介绍下怎么在Nginx配置HTTPS(SSL证书)。

部分配置如下:

    listen 80;
    listen 443 ssl;
    listen [::]:80;
    listen [::]:443 ssl;

    server_name m.test.com;
    index index.php index.html index.htm default.php default.htm default.html;
    root /www/wwwroot/m.test.com;

    if ($server_port !~ 443){
        rewrite ^(/.*)$ https://$host$1 permanent;
    }

    #SSL-START SSL相关配置,请勿删除或修改下一行带注释的404规则
    #error_page 404/404.html;
    ssl_certificate "/www/server/nginx/m.test.com.pem";
    ssl_certificate_key "/www/server/nginx/m.test.com.key";
    ssl_session_cache shared:SSL:1m;
    ssl_session_timeout  10m;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
    ssl_prefer_server_ciphers on;
    #SSL-END

Leave a Comment

豫ICP备19001387号-1