【问题标题】:SSL certificate works on subdomain but not main domain using cloudflare and certbotSSL 证书适用于子域,但不适用于使用 cloudflare 和 certbot 的主域
【发布时间】:2020-10-15 16:55:09
【问题描述】:

所以我管理域 britoanderson.com 并试图让 ssl 处理它。 我使用 certbot 为两个 www 制作证书。子域和主要 britoanderson.com 域。 我将 cloudflare 设置为“完整”加密模式。 出于某种原因,SSL 证书适用于https://www.britoanderson.com/,但不适用于网站拒绝打开的https://britoanderson.com/

这是我的 nginx 默认文件:

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


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


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

    root /var/www/html/;
    index index.php index.html index.htm;

    server_name britoanderson.com www.britoanderson.com;

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

        location ~ \.php$ {
                include snippets/fastcgi-php.conf;
                fastcgi_pass unix:/run/php/php7.0-fpm.sock;

        }
}

server {
        listen 443 ssl http2;
        listen [::]:443 ssl http2;


        ssl on;
        ssl_certificate /etc/letsencrypt/live/britoanderson.com/fullchain.pem; # managed by Certbot
        ssl_certificate_key /etc/letsencrypt/live/britoanderson.com/privkey.pem; # managed by Certbot

        root /var/www/html/;
        index index.php index.html index.htm;

        server_name britoanderson.com www.britoanderson.com;

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

        location ~ \.php$ {
                include snippets/fastcgi-php.conf;
                fastcgi_pass unix:/run/php/php7.0-fpm.sock;
        }

}

主域 britoanderson.com 和子域 www 的 A 记录均已在 cloudflare 上设置。

我做错了什么?为什么主网站直接拒绝打开?

【问题讨论】:

  • 不拒绝为我打开。
  • 我每次尝试访问 britoanderson.com 时都会收到 ERR_CONNECTION_TIMED_OUT ,但 www 子域确实有效。我什至尝试从不同的设备访问它,结果相同

标签: ssl nginx certbot


【解决方案1】:

您在颁发证书后是否重新启动了 nginx?我只能访问 http 站点,但不能访问 https 站点,因此您的 certbot 完成的 https 转发似乎也无法正常工作。

【讨论】:

  • 在过去的 5 个小时左右,我一直在搞乱该网站,也许我改变了一些破坏了它的东西,但现在它似乎在删除重定向后可以工作
【解决方案2】:

原来我的电脑给了我一个 DNS_PROBE_FINISHED_NXDOMAIN 而实际错误在重定向中。删除

if ($host = www.britoanderson.com) {
        return 301 https://www.$host$request_uri;
    } # managed by Certbot


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

修复了问题

【讨论】:

    猜你喜欢
    • 2019-12-28
    • 2016-10-17
    • 1970-01-01
    • 1970-01-01
    • 2018-08-10
    • 2017-10-03
    • 1970-01-01
    • 2016-09-27
    • 1970-01-01
    相关资源
    最近更新 更多