简体   繁体   English

Cloudfront多个来源和分布

[英]Cloudfront Multiple Origins and Distributions

I am having my site run on AWS and we are using Cloudfront for two origins: 我的网站在AWS上运行,我们将Cloudfront用于两个来源:

1) Main Site: EC2+ Loadbalancer 2) Blog: S3 1)主站点:EC2 +负载均衡器2)博客:S3

Then we created a behavior with /blog*, which we thought was that everything including Blog + Any article in Blog/ would go to the S3 website as well. 然后,我们使用/ blog *创建了一个行为,我们认为该行为包括Blog + Blog /中的任何文章在内的所有内容也都将转到S3网站。 Now our expectation was that they would link to the S3, so if someone hit www.mysite.com/blog it would go to S3, but it does not seem to work. 现在,我们的期望是它们将链接到S3,因此,如果有人访问www.mysite.com/blog,它将转到S3,但似乎不起作用。 For the /blog, nothing happens. 对于/ blog,什么也没有发生。

Then for anything eg /blog/article1.html we just get a "not exists" from S3, which means that we are not hitting the right endpoint. 然后对于任何东西,例如/blog/article1.html,我们只是从S3得到一个“不存在”,这意味着我们没有找到正确的终点。 So my questions: 所以我的问题是:

1) Is there a way to link /blog to S3 in this way? 1)是否可以通过这种方式将/ blog链接到S3?

2) Do we need to have mysite.com.s3-website-us-east-1.amazonaws.com/blog as the URL? 2)我们是否需要mysite.com.s3-website-us-east-1.amazonaws.com/blog作为URL? or can we have mysite.com.s3-website-us-east-1.amazonaws.com? 或者我们可以拥有mysite.com.s3-website-us-east-1.amazonaws.com?

3) Then would the articles need to be in: mywebsite.com.s3-website-us-east-1.amazonaws.com/blog or mywebsite.com.s3-website-us-east-1.amazonaws.com? 3)然后,这些文章是否需要放在:mywebsite.com.s3-website-us-east-1.amazonaws.com/blog或mywebsite.com.s3-website-us-east-1.amazonaws.com?

Seems Like we are doing something wrong. 好像我们做错了什么。 The fact that any change requires like 30 minutes of waiting does not help either... 任何更改都需要30分钟的等待时间这一事实也无济于事...

First of all, it is possible to do what you are planning. 首先,可以做您计划的事情。 Let me answer your questions inline. 让我直接回答您的问题。

1) Is there a way to link /blog to S3 in this way? 1)是否可以通过这种方式将/ blog链接到S3?

Yes. 是。 You can add the blog S3 Origin and behavior with route /blog/* to S3. 您可以使用路由/ blog / *将博客S3起源和行为添加到S3。

2) Do we need to have mysite.com.s3-website-us-east-1.amazonaws.com/blog as the URL? 2)我们是否需要mysite.com.s3-website-us-east-1.amazonaws.com/blog作为URL? or can we have mysite.com.s3-website-us-east-1.amazonaws.com? 或者我们可以拥有mysite.com.s3-website-us-east-1.amazonaws.com?

If you are hoping to map the same domain with subpath (aka /blog/article1.html) then you need to put the articles inside /blog/ path inside S3 bucket. 如果您希望使用子路径(aka /blog/article1.html)映射相同的域,则需要将文章放在S3存储桶的/ blog /路径内。 Make sure in the Origin config not to add any paths. 确保在Origin配置中不要添加任何路径。

3) Then would the articles need to be in: mywebsite.com.s3-website-us-east-1.amazonaws.com/blog or mywebsite.com.s3-website-us-east-1.amazonaws.com? 3)然后,这些文章是否需要放在:mywebsite.com.s3-website-us-east-1.amazonaws.com/blog或mywebsite.com.s3-website-us-east-1.amazonaws.com?

Articles needs to be inside /blog/ in S3. 文章需要在S3中的/ blog /中。 If you need to use a different routing mechanism you can still do it with Lambda Edge. 如果您需要使用其他路由机制,您仍然可以使用Lambda Edge。 But that require some coding. 但这需要一些编码。

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

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