简体   繁体   English

指向 S3 存储桶和 ELB 的 Cloudfront 分布

[英]Cloudfront distribution pointing to S3 bucket and ELB

I am trying to configure my cloudfront distribution to route requests for mydomain.com to an S3 bucket and requests for mydomain.com/api/* to an ELB.我正在尝试配置我的云端分发以将对 mydomain.com 的请求路由到 S3 存储桶并将对 mydomain.com/api/* 的请求路由到 ELB。

In route 53, I have dev.mydomain.com pointing to the cloudfront distribution with an alias record在路线 53 中,我有 dev.mydomain.com 指向带有别名记录的云端分布

Alias to cloudfront in route53 route53 中 cloudfront 的别名

I have configured two origins in cloudfront - one to S3 and one to a publicly accessible ELB我在云端配置了两个来源——一个到 S3,一个到可公开访问的 ELB

Cloudfront origins setup Cloudfront 起源设置

I have configured one (on top of default) behavior to route api/* requests to the ELB origin我已经配置了一个(在默认之上)行为来将 api/* 请求路由到 ELB 源

Cloudfront behaviors setup Cloudfront 行为设置

I have no issues with the S3 bucket.我对 S3 存储桶没有任何问题。 When I added the new behavior to route api/* requests to the ELB, I am receiving a 502 gateway error whenever I hit api/* routes.当我添加新行为以将 api/* 请求路由到 ELB 时,每当我点击 api/* 路由时,我都会收到 502 网关错误。

When I make a request to the ELB from the origin I provided to Cloudfront, I am seeing the following response in Postman:当我从提供给 Cloudfront 的来源向 ELB 发出请求时,我在 Postman 中看到以下响应:

Error: Hostname/IP does not match certificate's altnames: 
Host: mydomain-api-dev-env.us-east-1.elasticbeanstalk.com. is not in the cert's altnames: DNS:*.mydomain.com

This leads me to believe the 502 is because the ELB url is not included in mydomain.com's cert.这让我相信 502 是因为 ELB url 不包含在 mydomain.com 的证书中。

Assuming that this is my issue, how would I go about resolving this certificate issue since I don't own the elasticbeanstalk.com domain?假设这是我的问题,由于我不拥有 elasticbeanstalk.com 域,我将如何解决此证书问题 go?

You have to associate your own domain with the load balancer and add proper SSL to it.您必须将您自己的域与负载均衡器相关联,并向其添加正确的 SSL。 Then in your CF distro, you are going to use your own ALB's domain, not the one provided by AWS.然后在您的 CF 发行版中,您将使用自己的 ALB 域,而不是 AWS 提供的域。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM