AWS CloudFront可以同时提供动态和静态内容吗?

时间:2017-02-23 06:44:43

标签: amazon-web-services amazon-cloudfront

我们有一个基于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:

  3. 一般

        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模块

    3. 模式设置为" 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模块,从网站角度来看,一切都很好。

2 个答案:

答案 0 :(得分:1)

  

是否可以关闭静态和动态内容   CloudFront的?

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

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

答案 1 :(得分:0)

问题在于自签名证书。我从Comodo配置了免费的SSL,并且能够配置它。瞧! CloudFront能够识别它并从中提供我的内容。 谷歌Pagespeed指数也从74上升到85。

  

感谢@Michael - sqlbot澄清了我的观点。

相关问题