首页 > 解决方案 > 错误:SSL 配置错误(您与此站点的连接不安全)

问题描述

我在浏览器上遇到的确切错误:

This server could not prove that it is XXX.XX.XXX.XXX; its security certificate is from newDomain.live. This may be caused by a misconfiguration or an attacker intercepting your connection.

NGINX 配置:

server {
    # listen on port 443 (https)
    listen 443 ssl;
    server_name _;

    # location of the self-signed SSL certificate
    ssl_certificate /home/ubuntu/certs/server.pem;
    ssl_certificate_key /home/ubuntu/certs/server.key;


    # write access and error logs to /var/log
    access_log /var/log/app_access.log;
    error_log /var/log/app_error.log;

    location / {
        # forward application requests to the gunicorn server
        proxy_pass http://localhost:8000;
        proxy_redirect off;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
}

我做了什么:

我正在使用 AWS EC2 实例并将 NGINX 作为反向代理运行。如何解决 SSL 的这种错误配置?

标签: nginxnetworkingamazon-ec2opensslssl-certificate

解决方案


服务器返回的证书与 URL 中的名称不匹配。根据此描述,您已为 newDomain.live 创建了证书,但您尝试使用 IP 地址 xxx.xxx.xxx.xxx 访问该站点,这不是您创建的域。

如果域不是有效域(即没有 DNS 条目,您可以将域添加到本地主机文件,以 IP 作为目标,然后将域名作为地址在浏览器中。这将重定向到定义的 IP你的主机文件。

有关更多信息,请在 windows中更新主机,在 linux中更新主机。

解决方案:使用您注册证书的同一个域名访问该网站。

有关您遇到的类似错误的详细信息,请参阅此线程有关自签名证书错误的详细信息,请参阅此线程。

另一种方法:

这种方法不能解决您的 NGINX 问题。

你为什么不使用 NGINX,而不是使用Application Load Balancer在你的 EC2 实例前面。

然后使用 AWS Certificate Manager (ACM) 生成的证书,不仅证书免费,而且:

  • 它们由亚马逊签名,因此证书是可信的,如果您使用
  • DNS 验证证书在到期时自动轮换。

您可以在此处了解如何执行此操作。

您可以使用安全组将流量限制为来自负载均衡器,并且可以在负载均衡器前面使用Amazon CloudFront

ACM 最佳实践信息可在此处获得。


推荐阅读