我已经创建了域 (domain.com) 和子域 (abc.domain.com),并且还使用 letsencrypt 为两者生成了 SSL 证书。这两个 Django 项目都托管在 AWS EC2 上,并为它们创建了代理服务器,如下所示:
server {
listen 443 ssl;
server_name example.com;
location / {
proxy_pass https://1.2.3.4:444;
proxy_ssl_server_name on;
proxy_ssl_verify on;
proxy_ssl_certificate /home/domain/fullchain.pem;
proxy_ssl_certificate_key /home/domain/privkey.pem;
}
}
server {
listen 443 ssl;
server_name abc.example.com;
location / {
proxy_pass https://1.2.3.4:445;
proxy_ssl_server_name on;
proxy_ssl_verify on;
proxy_ssl_certificate /home/subdomain/fullchain.pem;
proxy_ssl_certificate_key /home/subdomain/privkey.pem;
}
}
我对代理服务器和两个项目进行了分析,开始时没有出现任何问题,问题是当我在浏览器上输入 https://example.com
时,它没有显示页面,但是当我用端口号拉域时。 https://example.com:444
,它开始显示页面。我不知道我错过了什么。
最佳答案
为了使 https://example.com
正常工作,您需要使用 SSL 配置正确配置 Nginx,其中包括使用 ssl_certificate
和 ssl_certificate_key
指令,因为您似乎没有使用它们。
使用 proxy_ssl_certificate
是为了在 Nginx 和代理服务器之间使用 HTTPS 连接,在您的例子中是 django 应用程序。
使用 ssl_certificate
是为了在用户的浏览器和 Nginx 之间使用 HTTPS 连接,您需要使 https://example.com
按预期工作
更多详情请查看configuring HTTPS servers
关于docker - ssl 证书或 nginx 代理服务器不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55016830/