代码之家  ›  专栏  ›  技术社区  ›  Daniel Santos

对于没有WWW和不使用CNAME的域,如何使用路由35将HTTP和HTTPS路由到CloudFront?

  •  1
  • Daniel Santos  · 技术社区  · 7 年前

    让我描述一下我的场景,我有:

    • EC2实例(Wordpress)
    • 为EC2实例提供 https的CloudFront分发,并重定向 http to https
    • A cname aws route 53 record that points www 。example.com to the cloudfront distribution.
    • AN A route 53 record that points root mydomain to ec2 ip.
    • 很多其他记录(MX、NS、SOA、TXT)都在根mydomain中。

    发生了什么:

    • _request https://strong>:/ www://strong>。example.com cloudfront services content with aws signed certificate.

    • _REQUEST http://STRONG>:/ www://STRONG>。example.com cloudfront redirects to https://STRONG>://www.example.com.

    • _REQUEST http ://example.com(不带www)my ec2 redirects to https :/ www 。example.com

    • _ request https ://example.com(without www), returns error cause ec2 does not service https

    我该怎么做才能避免这个错误呢?

    我无法将 cname record添加到根mydomain,因为 cname cannot co-exist with another records(mx,ns,soa,txt)

    我无法将 a路由到cloudfront,因为我找不到 i p的 for cloudfront distribution,可能没有 i p的 address. 重定向 HTTP协议 HTTPS .

  • CNAME AWS路线53记录这些点 万维网 .example.com到cloudfront发行版。
  • A 将根mydomain指向ec2 ip的路由53记录。
  • 很多其他记录(MX、NS、SOA、TXT)都在根mydomain中。
  • enter image description here

    发生什么事:

    • 请求请求 HTTPS :/ / 万维网 .example.com cloudfront提供带有AWS签名证书的内容。

    • 请求请求 HTTP协议 :/ / 万维网 .example.com CloudFront重定向到 HTTPS 网址:www.example.com。

    • 请求请求 HTTP协议 ://example.com(不带www)我的EC2重定向到 HTTPS :/ / 万维网 Excel

    • 请求请求 HTTPS ://example.com(不带www) 返回错误 因为EC2不起作用 HTTPS

    我该怎么做才能避免这个错误呢?

    我无法添加 cNeNe 记录到根mydomain,因为 cNeNe 不能与其他记录(MX、NS、SOA、TXT)共存

    我不能通过 录制到CloudFront,因为我没有找到 IP 对于云端分布,可能没有 知识产权 地址。

    1 回复  |  直到 7 年前
        1
  •  1
  •   John Hanley    7 年前

    对于 naked 域(域) example.com )使用类型为的Route 53记录集 A 使能 Alias 选择权。然后将CloudFront分布指定为 Alias Target . 逻辑上,这与设置CNAME非常相似。

    Routing Traffic to an Amazon CloudFront Web Distribution by Using Your Domain Name