I have a PHP app on AWS Elastic Beanstalk, I have created an assets bucket on S3. I'm trying to setup a Cloudfront distribution with behaviors to send requests for assets/* to S3 with a default behavior to send requests to EB. The domain points to Cloudfront.
我在AWS Elastic Beanstalk上有一个PHP应用程序,我在S3上创建了一个资产存储桶。我正在尝试使用行为设置Cloudfront分发,以将资产/ *请求发送到S3,并使用默认行为向EB发送请求。该域指向Cloudfront。
All requests are going to EB which returns a 404 since there is no assets diretory in the EB environment.
由于EB环境中没有资产指令,所有请求都将返回EB,返回404。
I have created 2 Cloudfront origins, one for EB and one for the S3 bucket. This is what my behaviors look like:
我创建了2个Cloudfront源,一个用于EB,一个用于S3存储桶。这就是我的行为:
Precedence Path Pattern Origin Protocol Policy Fwd Query Strings
0 assets/* S3-example-bucket HTTP and HTTPS No
1 Default (*) Custom-example.us-east-1.elasticbeanstalk.com HTTP and HTTPS Yes
It seems as though this should be pretty straight forward so I assume I'm missing something basic. Any help is greatly appreciated.
似乎这应该是非常直接的,所以我认为我缺少一些基本的东西。任何帮助是极大的赞赏。
Edit:
编辑:
Request header:
请求标题:
GET /assets/images/10waysaudiobook.png HTTP/1.1
Host: example.com
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:46.0) Gecko/20100101 Firefox/46.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Cookie: wordpress_logged_in_8a27500b7747be1e4fbad7f473f238e5=snickerspixy%7C1466021823%7Cr7rE5moINjanjHEqb1TGbsSkn9F7OCZLfX69IbcnGJu%7C28fc452885f3fe6e954243abab585a188f6511cdd6eeec6fa5ec5c50b9f3d393; wp-settings-7674=m4%3Do%26m5%3Do%26m9%3Do%26m6%3Do%26editor%3Dhtml%26m10%3Do%26m0%3Do%26m3%3Do%26hidetb%3D1%26m2%3Dc%26m1%3Do%26m8%3Do%26m12%3Do%26m7%3Do%26m11%3Do%26urlbutton%3Dnone%26m13%3Do%26tml1%3D1%26imgsize%3Dfull%26align%3Dcenter%26libraryContent%3Dbrowse%26ed_size%3D569%26unfold%3D1%26wplink%3D1%26mfold%3Do%26post_dfw%3Doff%26advImgDetails%3Dshow%26posts_list_mode%3Dlist; wp-settings-time-7674=1464816549; AWSELB=1FCB85F51606EBAFF15FEADB01C8069AEDE17E2A043407E615EF1A0E1ABF24607545A45D3DC206631F7AAE4503ADA423788B5E6B5B48FAE93EE916DE068509E64F92AC10FF; PHPSESSID=cpi2su7s967phu87rlpjgneel6; wordpress_test_cookie=WP+Cookie+check
Connection: keep-alive
Response header:
响应头:
HTTP/1.1 404 Not Found
Cache-Control: no-cache, must-revalidate, max-age=0
Content-Type: text/html; charset=UTF-8
Date: Sun, 05 Jun 2016 00:54:23 GMT
Expires: Wed, 11 Jan 1984 05:00:00 GMT
Link: <https://example.com/wp-json/>; rel="https://api.w.org/"
Pragma: no-cache
Server: Apache
Transfer-Encoding: chunked
Connection: keep-alive
1 个解决方案
#1
1
The response headers indicate that this request wasn't served by CloudFront at all, because there are headers that should be present... but are absent.
响应标头表明CloudFront根本不提供此请求,因为存在应该存在的标头但是不存在。
CloudFront adds Via:
, X-Cache:
, and x-amz-cf-id:
headers to every response, and sometimes Age:
(on cache hits and errors) or Vary:
if you're forwarding the CloudFront-Is-*-Viewer:
headers to the origin.
CloudFront将Via:,X-Cache:和x-amz-cf-id:标头添加到每个响应中,有时Age :(在缓存命中和错误上)或Vary:如果您要转发CloudFront-Is - * - Viewer:标题到原点。
The absence of these headers suggest that the DNS for the site hasn't been pointed to CloudFront and may still be pointing directly to the EB environment, or if the change was recent, that the former TTL for the DNS entry may not yet have expired.
缺少这些标头表明该网站的DNS尚未指向CloudFront,并且可能仍然直接指向EB环境,或者如果更改是最近的,则DNS条目的前TTL可能尚未过期。