0

Lets say that I have an S3 bucket called apps.buildmysite.com for my hypothetical website buildmysite.com (I also have buildmysite.com and www.buildmysite.com as S3 buckets which host the main website).

Inside the S3 bucket is a list of folders:

  • app-2343242

  • app-9402932

Each app corresponds to a separate website. I now want to create the corresponding subdomains for the above folders. So in effect:

  • app-2343242 -> http://apps.buildmysite.com.s3-website-eu-west-1.amazonaws.com/app-2343242
  • app-9402932 -> http://apps.buildmysite.com.s3-website-eu-west-1.amazonaws.com/app-9402932

So when someone visits app-2343242.buildmysite.com, they are served a file residing at http://apps.buildmysite.com.s3-website-eu-west-1.amazonaws.com/app-2343242/index.html.

How would I accomplish this?

methuselah
  • 12,766
  • 47
  • 165
  • 315
  • You can't do this with S3 alone, because it does not have the necessary configurability -- you need a reverse proxy with header rewrite capabilities in conjunction with S3. I'm marking this as a duplicate of [Serving a multitude of static sites from a wildcard domain in AWS](https://stackoverflow.com/q/49812706/1695906), where I explained how CloudFront and Lambda@Edge can accomplish this. – Michael - sqlbot Jan 04 '20 at 22:49
  • Hi Michael, yes I managed to fix it with your instructions. Thank you very much! – methuselah Jan 05 '20 at 01:07
  • I am having another issue though - discussed here: https://stackoverflow.com/questions/59598350/lambda-script-to-direct-to-fallback-s3-domain-subfolder-when-not-found. It's to do with creating a fallback approach whenever a S3 domain subfolder is not found. – methuselah Jan 05 '20 at 08:58

0 Answers0