nginx - 错误: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;
}
}
我做了什么:
- 跑进
openssl req –new –newkey rsa:2048 –nodes –keyout server.key –out server.csr
终端 - 从服务器复制
server.csr
到 SSL 提供商,因为它要求来自网络托管的 CSR - 提供商颁发的 SSL 证书有两个字段 1. 服务器证书 2. CA 证书(中间和根)
- 此时我已经检查过,但它仍然未经验证,无法建立 https 连接。
- 然后,我从服务器中删除了该
server.csr
文件,并通过复制 SSL 提供商提供的“1. 服务器证书”创建了一个新文件。
我正在使用 AWS EC2 实例并将 NGINX 作为反向代理运行。如何解决 SSL 的这种错误配置?
解决方案
服务器返回的证书与 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 最佳实践信息可在此处获得。
推荐阅读
- css - 由于 div 包含引导 css,Angular 6 ngb-bootstrap 模式未显示
- jquery - 无法在 jquery 中设置复选框属性的值
- c++ - 将 std::future 和 std::promise 与非 std::thread 一起使用是否安全?
- powershell - 如何在 Powershell 模块文件中使用类型加速器?
- php - 如何在 Laravel 中分离控制器方法?
- python - Python,将 x = 0 放入 '' 括号中
- angular - 为什么 materializecss 和 *ngFor 的轮播不能动态协同工作以获取图像和内容项
- angular - 如何从 html 传递一个值以供其他组件函数使用 Typescript
- php - 具有大量选项的 HTML Select2
- ios - 在collectionview的部分中以id方式显示图像