简体   繁体   English

Cloudfront 具有 2 个来源(不同的存储桶)和存储桶的两个主机根

[英]Cloudfront with 2 origins (different buckets) and both host root of bucket

I have a CDN and 2 buckets我有一个 CDN 和 2 个存储桶

  • one bucket is using the default behaviour so img.png is accessible via CDN URL: cdn.com/img.png一个桶使用默认行为,以便img.png是通过CDN URL访问: cdn.com/img.png

  • one bucket is using the /path behaviour so everything in the CDN routed to /path should go to this bucket.一个存储桶正在使用/path行为,因此路由到 /path 的 CDN 中的所有内容都应转到此存储桶。 It works when i put this in the bucket: path/test.png .当我将它放入存储桶时它会起作用: path/test.png I can visit cdn.com/path/test.png .我可以访问cdn.com/path/test.png

What I want is to put test.png in the root of my bucket without the prefix of path/ .我想要的是将test.png放在我的存储桶的根目录中,而没有path/的前缀。 Is this possible (without the use of lambda@edge)?这可能吗(不使用 lambda@edge)?

If you want to rewrite the path, you have to use lambda@edge.如果要重写路径,则必须使用 lambda@edge。

If you are ok with 301 redirection, you can try enabling static website hosting on S3 bucket and use the following redirection rule :如果您对 301 重定向没问题,您可以尝试在 S3 存储桶上启用静态网站托管并使用以下重定向规则

<RoutingRules>
  <RoutingRule>
    <Condition>
      <KeyPrefixEquals>path/</KeyPrefixEquals>
    </Condition>
    <Redirect>
      <ReplaceKeyPrefixWith/>
    </Redirect>
  </RoutingRule>
</RoutingRules>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM