davids
davids

Reputation: 6371

Resolve S3 static page from custom path with CloudFront

I've got an S3 bucket configured to host a static website, and if I browse to the bucket URL it shows the index.html file. I also have a CloudFront distribution to show another S3 bucket under a custom domain. Is there any chance I could configure CloudFront to serve one bucket from the root and another from a custom path? So:

  mydomain.com            -> bucket1/index.html
  mydomain.come/some-path -> bucket2/index.html

I already created an origin for the bucket and set up a path pattern for it and some-path, but I'm getting 403 Forbidden, even though if I browse to the origin directly I can see the webpage.

Upvotes: 4

Views: 1638

Answers (1)

Michael - sqlbot
Michael - sqlbot

Reputation: 179154

This configuration works fine, but it requires that the object in bucket2 be located at some-path/index.html inside bucket2.

The path pattern you configured in the cache behavior is still part of the request path, so it is forwarded to the origin.

CloudFront does not support removing part of the request path before forwarding the request to the origin.

Upvotes: 2

Related Questions