SSL仅适用于没有www

时间:2015-06-07 15:34:16

标签: ssl nginx server ssl-certificate

如果我的网址为site.com而非www.site.com,则我的SSL证书可以正常运行。为什么会这样,我该如何解决?当我配置我的CSR和证书时,它说使用mysite.com作为域,而不是www.mysite.com,因为它会自动配置www

这是我的nginx配置:

ssl_certificate /etc/nginx/ssl/bundle.crt;
ssl_certificate_key /etc/nginx/ssl/myserver.key;
ssl_session_timeout 10m;
ssl_session_cache shared:SSL:10m;
ssl_dhparam /etc/nginx/ssl/dhparams.pem;
ssl_protocols TLSv1.1 TLSv1.2;
ssl_ciphers 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-$
ssl_prefer_server_ciphers on;
ssl_stapling on;
ssl_stapling_verify on;



server {
    listen 80;
    listen 443 ssl;
    keepalive_timeout 70;
    access_log /var/www/mysite.com/logs/access.log;
    error_log /var/www/mysite.com/logs/error.log;
    root /var/www/mysite.com/public_html/mysite/public/_main;
    server_name www.mysite.com mysite.com;

    # HSTS - 6 months
    add_header Strict-Transport-Security "max-age=15768000; includeSubDomains";
    resolver 192.0.2.1;

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

    location ~ \.php$ {
            try_files $uri =404;
            include /etc/nginx/fastcgi_params;
            if ($uri !~ "^/assets/images/") {
                    fastcgi_pass unix:/var/run/php-fastcgi/php-fastcgi.socket;
            }
            fastcgi_index landing.php;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }
}

1 个答案:

答案 0 :(得分:1)

通常情况恰恰相反。如果您在CSR中指定www.yoursite.com作为通用名称,则该证书将与www.yoursite.com和yoursite.com一起使用。