Nginx certbot SSL 无法与 Cloudflare 配合使用

问题描述 投票:0回答:2

最近迁移到 CloudFlare,因为我想要一个 DNS 服务,为 certbot 提供 DNS 凭据以生成通配符 SSL 证书。

但是,我正在努力运行基本的 SSL Nginx 设置。

背景:

  1. DNS解析工作正常。 (当我只有一个 Nginx HTTP 服务器块时,网站通过 HTTP 加载不安全)
  2. 可以通过带有 HTTPS 地址的直接 IP 连接到网站(不通过 CloudFlare IP)。它给出了无效的证书警告,但仍然连接。
  3. openssl s_client -connect property-connect.co.uk:443 -servername property-connect.co.uk
    看来SSL证书没问题

步骤:

  1. Ran
    certbot --nginx
    指定包括两个域 (www.property-connect.co.uk property-connect.co.uk)
  2. sudo nginx -t
    成功了
  3. sudo nginx -s reload

nginx.conf

events {

}

http {
  server {
    server_name www.property-connect.co.uk property-connect.co.uk;

    listen [::]:443 ssl ipv6only=on; # managed by Certbot
    listen 443 ssl; # managed by Certbot

    location / {
       proxy_pass http://localhost:700;
    }

    ssl_certificate /etc/letsencrypt/live/property-connect.co.uk-0001/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/property-connect.co.uk-0001/privkey.pem; # managed by Certbot

  }
}

对于这个基本配置我缺少什么有什么想法吗?

ssl nginx cloudflare certbot
2个回答
3
投票

您当前该域的证书由 Cloudflare 本身颁发和管理,而不是由您的 CertBot/Nginx 颁发和管理:

$ openssl s_client -connect property-connect.co.uk:443 -servername property-connect.co.uk  </dev/null 2>&1 | grep ^issuer
issuer=C = US, ST = CA, L = San Francisco, O = "CloudFlare, Inc.", CN = CloudFlare Inc ECC CA-2

我猜这是因为您已通过 Cloudflare 将流量代理到您的主机

您应该将您的域名切换到

DNS only
,然后您将能够直接连接到您的 Nginx,而无需 Cloudflare 反向代理。


1
投票

原来我只需要更改 Cloudflare SSL 设置

Websites > example.com > SSL/TLS > Overview > Flexible

Websites > example.com > SSL/TLS > Overview > Full
.

© www.soinside.com 2019 - 2024. All rights reserved.