AWS CloudFront 能否同时提供动态和静态内容?

Can AWS CloudFront serve both dynamic and static content?

我们有一个基于 Drupal7 的电子商务网站,我正尝试将其托管在 AWS 中。我想知道,AWS CloudFront 能否同时用于提供静态和动态内容?也许,创造两个起源或类似的东西?虽然只是一个疯狂的猜测。 使用 CDN 的原因是为我们的 js、css 和图像提供服务。这些文件存储在 EFS 中。我没有选择 S3,因为我觉得它很麻烦,而且我需要在 Drupal 上安装另一个 S3FS 模块并对其进行配置。总之就是不想走那条路。此外,我所在的地区没有 EFS,所以我不得不在爱尔兰托管该站点,因此需要 CDN。 然而,是否可以在 CloudFront 之外同时提供静态和动态内容?

另一个问题是,CloudFront 是否支持自签名证书?在测试时,我有一个使用自签名证书创建的测试域,但是当我将它提供给 CloudFront 时,它会抛出错误。我认为使用自签名是不可能的,是吗?

PS。我让 Route53 指向 Cloudfront DNS

已更新

让我解释一下我执行的整个步骤:

  1. 将自签名证书添加到 chrome 和我的系统,现在我没有看到一个页面说它不安全.. 所以到这里一切都很好。 enter image description here

  2. 创建了具有以下设置的 CloudFront:

一般

    Distribution ID E2RDLVLNKPEXQ9

    ARN arn:aws:cloudfront::xxxx:distribution/E2RDLVLNKPEXQ9

    Delivery Method Web

    Cookie Logging  Off

    Distribution Status Deployed

    Price Class Use All Edge Locations (Best Performance)

    State   Enabled

    Alternate Domain Names (CNAMEs) 
    *.kiirana11.com

    SSL Certificate Default CloudFront Certificate (*.cloudfront.net)

    Domain Name xxxx.cloudfront.net

    Custom SSL Client Support   -

    Supported HTTP Versions HTTP/2, HTTP/1.1, HTTP/1.0

    IPv6    Enabled

    Last Modified   2017-02-24 09:41 UTC+5:30

来源

Origin Domain Name
xxxxelb-1927396229.eu-west-1.elb.amazonaws.com

Origin ID
PPRD-kirana11elb    

Origin SSL Protocols
TLSv1.2
TLSv1.1
TLSv1
SSLv3

Origin Protocol Policy
HTTP Only
HTTPS Only
Match Viewer

HTTP Port
80

HTTPS Port
443

行为

Path Pattern
Default (*)     

Origin
PPRD-kirana11elb

Viewer Protocol Policy
HTTP and HTTPS

Allowed HTTP Methods
GET, HEAD, OPTIONS, PUT, POST, PATCH, DELETE

Cached HTTP Methods
GET, HEAD +OPTIONS 

Forward Headers
Whitelist

Whitelist Headers
CloudFront-Forwarded-Proto
Host

Object Caching
Use Origin Cache Headers
Minimum TTL
0
Maximum TTL
31536000
Default TTL
86400

Forward Cookies
All

Query String Forwarding and Caching
Forward all, cache based on all

Smooth Streaming
No

Restrict Viewer Access
No

Compress Objects Automatically
No

CloudFront 当前状态已启用并已部署

  1. 已在 Route53 中加载 CloudFront。出于某种原因,它没有自动加载 A 名称,我不得不强行输入云端 DNS 名称。

  2. 已安装 Drupal CDN 模块

模式设置为"Origin Pull",CDN映射有cLOUDfRONT url WITH https

现在开始问题:

[root@ip-10-1-36-192 ec2-user]# curl https://xxxx.cloudfront.net
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML><HEAD><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<TITLE>ERROR: The request could not be satisfied</TITLE>
</HEAD><BODY>
<H1>ERROR</H1>
<H2>The request could not be satisfied.</H2>
<HR noshade size="1px">
CloudFront wasn't able to connect to the origin.
<BR clear="all">
<HR noshade size="1px">
<PRE>
Generated by cloudfront (CloudFront)
Request ID: Fvf4qfAwuzBRS4J_SA6p1I-UYnvqSuZxdvXV1E6HuGEMGOxWPeORsQ==
</PRE>
<ADDRESS>
</ADDRESS>
</BODY></HTML>You have new mail in /var/spool/mail/ec2-user

[root@ip-10-1-36-192 ec2-user]# curl -Ik https://website.com
HTTP/1.1 200 OK
Cache-Control: no-cache, must-revalidate
Content-Language: en
Content-Type: text/html; charset=utf-8
Date: Fri, 24 Feb 2017 05:50:46 GMT
Expires: Sun, 19 Nov 1978 05:00:00 GMT
Server: Apache/2.4.25 (Amazon) OpenSSL/1.0.1k-fips mod_fcgid/2.3.9
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-Generator: Drupal 7 (http://drupal.org)
X-UA-Compatible: IE=edge,chrome=1
Connection: keep-alive

整个 sie 都被 CDN 搞砸了,这就是我所看到的

enter image description here

如果我禁用 CDN 模块,从网站的外观和感觉来看一切都很好。

is it possible to serve both static and dynamic content off CloudFront?

是的,CloudFront 也提供动态内容。这可以是 PHP 内容等。 您的来源可以是 S3 或 Web 服务器(aws 实例)等。请阅读 CloudFront 文档以了解有关其工作原理的详细信息。

是的,CloudFront 支持自签名证书。您可以详细说明您采取了哪些步骤来设置它。或者,请在此处查看文档:http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/cnames-and-https-requirements.html

问题出在自签名证书上。我已经从 Comodo 提供了一个免费的 SSL,并且能够对其进行配置。瞧! CloudFront 能够识别它并且我的内容是从它提供的。 Google Pagespeed 指数也从 74 跃升至 85。

Thanks @Michael - sqlbot for clarifying the point to me.