CloudFront的分布与自定义地重定向请求 [英] CloudFront Distribution with Custom Origin Redirects Request

查看:186
本文介绍了CloudFront的分布与自定义地重定向请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我成立了一个CloudFront的分布与<一个工作href="http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/WorkingWithDownloadDistributions.html#DownloadDistS3AndCustomOrigins"相对=nofollow>自定义起源 - 。我的客户的Web服务器( www.mydomain.com

I set up a CloudFront distribution to work with a Custom Origin - my client's web server (www.mydomain.com).

当我打开我的网页,并检查了Chrome网络检查的网络选项卡,资产显示为来​​自原始服务器未来(www.mydomain.com <$ C C $>),而始作俑者栏显示CloudFront的URL作为重定向。我认为这意味着该CloudFront的被重定向资产请求我的原始服务器,其中pretty的太多失败的目的。

When I load my webpage and check the Network tab of the Chrome web inspector, the assets are shown as coming from the origin server (www.mydomain.com), and the "Initiator" column shows the CloudFront URL as a redirect. I take that to mean that CloudFront is redirecting the asset request to my origin server, which pretty much defeats the purpose.

当我设置的发行,我离开了TTL的默认值,而我认为是指24小时。

When I set up the distribution, I left the TTL at the default value, which I believe means 24 hours.

如果我用一个S3桶为原点,而不是Web服务器,资产直接从CloudFront的正常加载。

If I use an S3 bucket as the origin instead of a web server, the assets load directly from CloudFront as expected.

推荐答案

如果你看到的URL资产在自己的服务器领域,这意味着CloudFront的收到重定向响应时,它跑回去取的资产,并服务于该重定向作为高速缓存的结果。这绝对不是你想要的。

If you see your own server domain in the URL for the asset, it means that CloudFront received a redirect response when it went to fetch the asset and is serving that redirect as the cached result. This is definitely not what you want.

我有,我看到这个帖子上的答案之一后,解决了类似的问题:

I had a similar problem that I solved after seeing one of the answers on this post:

<一个href="http://stackoverflow.com/questions/12606487/magento-amazon-cloudfront-cdn-and-caching/12611994#12611994">Magento - 亚马逊的Cloudfront CDN和缓存

我是从domain.com重定向到www.domain.com和CloudFront的是缓存并返回一个重定向。你可能会看到同样的事情与HTTP / HTTPS重定向。

I was redirecting from domain.com to www.domain.com and CloudFront was caching and returning that redirect. You would probably see the same thing with an http/https redirect.

如果你正在做一个HTTP - > HTTPS重定向,你有两个选择:你可以​​服务于资产CloudFront的HTTP或使CloudFront的要求他们为HTTPS。对于后者,你就需要配置CloudFront的起源速配交友浏览器。这意味着,如果观众正在使用HTTPS,CloudFront的还将。如果用户使用的是HTTP,CloudFront的将要求在HTTP,返回HTTPS重定向到从服务器接收,并在客户端随后将重新发出请求作为HTTPS。

If you're doing an HTTP -> HTTPS redirect, you have two options: You can either serve the assets to CloudFront as HTTP or make CloudFront request them as HTTPS. To do the latter, you would need to configure your CloudFront origin to "Match Viewer." That means that if the viewer is using HTTPS, CloudFront will also. If the user is using HTTP, CloudFront would request in HTTP, return the HTTPS redirect it received from your server, and the client would then re-issue the request as HTTPS.

在我们的情况下,自己不需要的资产将在飞行中受到保护。他们是从CloudFront的担任HTTPS让用户的浏览器是看到所有的HTTPS内容是唯一重要的。因此,在我们的情况下,也没有必要将资产CloudFront的充当HTTPS。不管它是如何获取从我们的服务器的内容,CloudFront的匹配观众的协议时,它的响应。

In our case, the assets themselves do not need to be protected in-flight. It is only important that they are served from CloudFront as HTTPS so the user's browser is seeing all HTTPS content. So, in our case, it is not necessary to serve the assets to CloudFront as HTTPS. Regardless of how it fetches the content from our server, CloudFront will match the viewer's protocol when it responds.

这篇关于CloudFront的分布与自定义地重定向请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆