nginx www 到非 www https 重定向

nginx www 到非 www https 重定向

我正在尝试路由www.intelehealth.orghttps://intelehealth.org然而每当我点击该网址www.intelehealth.org它给了我

ERR_CERT_COMMON_NAME_INVALID

我的 nginx 配置是

server {

        root /var/www/wordpress;

        # Add index.php to the list if you are using PHP
        index index.php index.html index.htm index.nginx-debian.html;

        server_name intelehealth.org;

location ~ \.php$ {
    include snippets/fastcgi-php.conf;
    fastcgi_pass unix:/run/php/php7.4-fpm.sock;
}
# Disables Favicon Logging & Errors
location = /favicon.ico {
    log_not_found off;
    access_log off;
}
# Disables Robots.txt Logging & Errors
location = /robots.txt {
    allow all;
    log_not_found off;
    access_log off;
}
# Denies Access to Hidden Files
location ~ /\. {
    deny all;
}
# Blocks PHP files in Upload Directory
location ~* /(?:uploads|files)/.*\.php$ {
    deny all;
}
# Enable WordPress Permalinks Support (default .htaccess replacement)
location / {
    try_files $uri $uri/ /index.php?$args;
}


    listen [::]:443 ssl ipv6only=on; # managed by Certbot
    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/intelehealth.org/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/intelehealth.org/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

}

server {
    if ($host = intelehealth.org) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


        listen 80 default_server;
        listen [::]:80 default_server;

        server_name intelehealth.org;
    return 404; # managed by Certbot

}

我已经设置了 cname 记录www.intelehealth.org

如下图所示

知道我遗漏了什么吗?

谢谢

答案1

您的证书缺少 DNS 名称www.intelehealth.org,它仅对 有效intelehealth.org。请重新创建证书以使其包含两个域,或为另一个域创建新证书。

相关内容