Host S3 website with on-premises DNS server without Route53
I have an S3 bucket set up for "Static Website Hosting", a CloudFront distribution with our own SSL certificate and allowing Host header, a Global Accelerator IP address attached to an Application Load Balancer.
The Application Load Balancer does a 301 redirect to the S3 bucket. I know that you can set an EC2 instance as a target group and forward to that to preserve the original URL.
Can you also preserve the original URL using this method of 301 redirect to a Cloudfront distribution tied to an S3 bucket?
I'm a little unclear about what you're trying to do here.
If I follow correctly: Browser navigates to firstexample.com
(hosted on ALB/EC2) which then redirects to secondexample.com
(hosted on CloudFront/S3). You're looking for a way such that the browser doesn't see secondexample.com
once redirected but firstexample.com
instead?
By setting up (say) static.firstexample.com
on CloudFront you can then pull static content from any S3 bucket you like. Then the redirect would be to static.firstexample.com
. But you can't have the same hostname firstexample.com
used for both CloudFront and ALB - well, not without randomly sending browser to either location.
However, the subject of your question mentions Route 53. In this case, if you're hosting content on firstexample.com
you do need Route 53 in order to assign the "apex record" to a specific endpoint (ALB, CloudFront, whatever). If you were redirecting from www.firstexample.com
to www.secondexample.com
or static.firstexample.com
then an on-premises DNS will work fine. Naturally, my next question would be "why not use Route 53 given it is a fully managed and highly available service".
I'm not sure why using Route 53 means dedicating a portion of your IP address space to Route 53. The only restriction here is that apex records are assigned to Route 53 Alias records which necessitates those resource being in AWS. But that has nothing to do with IP addressing.
Relevant questions
Using Lightsail with Cloudfront
asked 2 years agoHow do I use Amazon CloudFront with AWS Elastic Beanstalk as the origin?
Accepted AnswerHost S3 website with on-premises DNS server without Route53
Accepted Answerasked 2 months agoStatic website in S3 not working with HTTPS
asked 2 years agoRoute53 custom domain not updating content
asked 2 months agoHow can I use the same domain name in different AWS accounts?
asked 3 years agoOAI or not OAI for serving a static website in S3 using CloudFront
asked a month agoAdding Domain Name to CloudFront Distribution
Accepted Answerasked 5 months agoconnecting Route 53 domain to Big Cartel
asked 2 years agoS3 Static Website RoutingRules when using Cloudfront and a domain name
asked 3 years ago
I wanted to keep the original domain entered into the browser while serving up content from the S3 bucket. We did not want to use Route53 as that would require us to dedicate a portion of our IP address space to Route53 and that may change in the future. The question was incomplete and should have provided more detail. You were right in guessing what I was actually trying to do. In this case, I think we should use ALB/EC2 forwarding to an EC2 managed by Elastic Beanstalk.