大网数据广告活动
服务器运维问答

I'm getting SSL_ERROR_BAD_CERT_DOMAIN for my www subdomain

· 52CE 我爱测

Server: Ubuntu, nginx. I have a domain example.com registered at namecheap.com and configured at DigitalOcean. I have CNAME record for www subdomain: www.example.com. 1800 IN CNAME example.com. Here is my /etc/nginx/sites-enabled…

问题原文

原帖链接 · Andrey Gordeev · CC BY-SA 3.0

Server: Ubuntu, nginx.

I have a domain example.com registered at namecheap.com and configured at DigitalOcean. I have CNAME record for www subdomain:

www.example.com. 1800 IN CNAME example.com.

Here is my /etc/nginx/sites-enabled/default file content:

# HTTP - redirect all requests to HTTPS
server {
    listen 80;
    listen [::]:80 default_server ipv6only=on;
    return 301 https://$host$request_uri;
}

# HTTPS - serve HTML from /usr/share/nginx/html, proxy requests to /parse/
# through to Parse Server

server {
    listen               80;
    server_name          www.example.com;

    return 301 https://example.com$request_uri;
}

server {
        listen 443;
        server_name example.com;

        root /home/example/website;
        index index.html index.htm;

        ssl on;
        # Use certificate and key provided by Let's Encrypt:
        ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
        ssl_session_timeout 5m;
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_prefer_server_ciphers on;
        ssl_ciphers 'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH';

        # Config (http://www.westphahl.net/blog/2012/01/03/setting-up-https-with-nginx-and-startssl/)
        add_header Strict-Transport-Security max-age=31536000;
        add_header X-Frame-Options DENY;

        # Pass requests for /parse/ to Parse Server instance at localhost:1337
        location /parse/ {
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header X-NginX-Proxy true;
                proxy_pass http://localhost:1337/;
                proxy_ssl_session_reuse off;
                proxy_set_header Host $http_host;
                proxy_redirect off;
        }

        location / {
                try_files $uri $uri/ =404;
        }

}

However, when I'm trying to open www.example.com Firefox shows SSL_ERROR_BAD_CERT_DOMAIN "Your connection is not secure" error.

How to fix that?

ANSWER: Thanks to all suggesters, issuing an SSL certificate to www subdomain did the trick.

Here is a command for Let's Encrypt:

./letsencrypt-auto certonly --standalone -d example.com -d www.example.com

已采纳解答

原帖链接 · Matt Clark · CC BY-SA 3.0

Output from Chrome's Warning Page

This server could not prove that it is www.example.com; its security certificate is from example.com. This may be caused by a misconfiguration or an attacker intercepting your connection.

The certificate has been issued to the top level domain, example.com, but not the the subdomain www.exmample.com.

If the ssl issuer says that they are supposed to give you www, check with them for more information.

Note that this warning is coming at the SSL handshake level, and is before the request ever reaches the nginx server for processing.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2016-03-26)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。