【发布时间】:2019-10-28 15:32:41
【问题描述】:
我在尝试通过 https 使用自定义域名从 AWS s3 存储桶提供文件时遇到问题。
我今天有什么:
- 带有 sub.domain.com.s3-xxxxxxx.com 访问 url 的 s3 存储桶
- 将 sub.domain.com 重定向到我的一个 ec2 实例的 IP 的 DNS 设置。
- 上面提到的 ec2 实例带有一个运行我的 NGINX 配置的 docker 容器。
- certbot 安装在同一实例上。
我想做什么:
我被困在哪里:
- Certbot 不会为 sub.domain.com 生成 ssl 证书。
我尝试将所有对 sub.domain.com 的请求重定向到我在 NGINX 实例上运行的现有网站。 想法是生成证书,然后将其用于重定向到我的存储桶,因为 certbot 无法在 s3 存储桶中创建 .well-known/acme-challenges。
即使这样也行不通。我有点卡在这里。我只需要使用 let's encrypt 生成证书,以便让我的自定义域名重定向到 https。显然我需要稍后更新它,但我想一旦有效地创建证书就不会成为问题。
提前致谢。
编辑:忘记发布错误,这里是(用示例替换我的域名):
Failed authorization procedure. sub.domain.com (http-01): urn:ietf:params:acme:error:unauthorized :: The client lacks sufficient authorization :: Invalid response from http://sub.domain.com/.well-known/acme-challenge/xxxxx
还有我的 nginx 配置:
server {
listen 80;
server_name sub.domain.com;
rewrite ^/(.*)/$ /$1 permanent;
client_max_body_size 11m;
gzip on;
gzip_types text/plain application/javascript application/x-javascript text/javascript text/xml text/css;
error_log /var/log/nginx/project_error.log;
access_log /var/log/nginx/project_access.log;
root /var/www/html;
location / {
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
try_files $uri $uri/ /index.html =404;
autoindex on;
}
只需复制/粘贴我的网站 conf 服务实际站点文件的部分。
【问题讨论】:
-
比起使用
https://sub.domain.com.s3-xxxxxxx.com,你愿意使用https://s3-xxxxxxx.com/sub.domain.com/吗?这样,它将使用 S3 证书。如果这是不可接受的,那么将自定义域名与 SSL 结合使用的唯一方法是通过 Amazon CloudFront。 -
感谢您的回复。这确实是不能接受的。无论如何,我犯错的原因是很合乎逻辑的。 Certbot 无法在 s3 存储桶上创建 .well-known 目录。我最终使我的 NGINX conf 文件指向我的一个站点以生成证书,然后将其修改为指向我的存储桶......这是一个非常肮脏的解决方案,我建议任何人使用 aformentionned CloudFront 解决方案。
-
澄清一点:您不是在尝试将
https://sub.domain.com重定向到https://sub.domain.com.s3-xxxxxxx.com,您实际上是在尝试代理https://sub.domain.com到https://sub.domain.com.s3-xxxxxxx.com。另外,您是否有任何理由尝试通过运行 Nginx 的 EC2 实例而不是使用 CloudFront 来执行此操作?
标签: amazon-web-services nginx amazon-s3 lets-encrypt