CloudFront to redirect URL - amazon-cloudfront

I have CloudFront setup for domain.com to server static contents from S3 and everything else from ELB -> EC2
Want to setup permanent redirect for domain.ca to domain.com. Haw can I do this in CloudFront ?
Is Lambda#Edge efficient way ? https://aws.amazon.com/blogs/networking-and-content-delivery/handling-redirectsedge-part1/

Related

Base64 Image redirection problem on Drupal integrated with Cloudfront

I am receiving some issues on Drupal.
I have integrated Amazon cloudfront with Drupal.
The Cloudfront origin for my domain is drupal.example.com and Cnames are www.example.com and example.com.
The problem is that some images are
are forming the URL's like this
data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7
Please suggest.

Cloudfront with custom origin and identical domain

Let's say a website with the domain www.example.com is hosted on a LAMP server of a webhoster, which is not Amazon. The domain is managed by Route53.
Is it possible to somehow keep all settings on the LAMP webserver and still use www.example.com as the domain for Cloudfront? Like:
Client -> www.example.com -> Cloudfront Edge Server -> Custom origin available over www.example.com on LAMP webserver of third party webhoster
Basically, I want to use www.example.com for both the Cloudfront Edge Server and the LAMP server.
Best regards
You cannot do anything like /etc/hosts on CloudFront -- it always uses public DNS to resolve the origin.
However, you can still do what you are trying to do -- but you just need to understand why this solution is indeed what you want, because it will seem like it is not (as you indicated in comments).
In Route 53, create a new A record for a new hostname for the origin server, such as origin.example.com. You do not configure this value anywhere on your origin server at all. Your origin server still believes it is www.example.com.
In Route 53, create an alias A record www.example.com pointing to origin.example.com.
At this point, your site works exactly as you expect and require. The hostname "origin.example.com" is in the resolution path, but this information is invisible and unknown to the origin.
In CloudFront, create a distribution, setting the origin domain name to origin.example.com and the Alternate Domain Name for the distribution to www.example.com.
In the settings for each Cache Behavior, ensure that the Host header is whitelisted for forwarding to the origin.
Change Route 53's alias for www.example.com to point to your CloudFront distribution.
When requests arrive at CloudFront, the request retains the Host: www.example.com header. CloudFront uses DNS to find the IP address for origin.example.com however, it only uses this information to make the connection to the origin. The incoming request is still addressed to www.example.com. If the origin has an SSL certificate for www.example.com, CloudFront will accept it as valid, because you configured the Host header for whitelisting, and it matches the cert.
In this configuration, accessing the CloudFront distribution with the assigned dzczcexample.cloudfront.net hostname in the browser's address bar will not work, because CloudFront will send that hostname to the origin, but once you point the Route 53 alias for www.example.com to the assigned cloudfront.net domain name, requests will be processed correctly.

AWS Cloudfront redirected you too many times

I have a problem with redirects in cloudfront.
I configure Cloudflare two NS in my webpanel first.
I follow this steps after this:
https://stackoverflow.com/a/42869783/3332734
In cloudfront I pointed my two buckets.
In my two buckets, I set hosting website and redirect with bestdestiny.panel.adm.br with https prefix
See my buckets config below:
and each bucket has the respective policy rule:
And this is my cloudfront config below:
but...

how to rewrite my application url to my domain in AWS

I have EC2 instance created in AWS the ip is for example 54.26.12.***
I have my domain (mydomain.com) registered with S3bucket for this EC2 instance, Now this domain shows the index page provided by AWS.
Now 54.26.12.*** is available while hitting mydomain.com in browser.
In this instance, I deployed a war file to tomcat server and I am able to run this as mydomain.com:8080/myAppUrl.
I am looking for show this application url while hitting mydomain.com in browser.
I can put .htaccess file to rewrite urls. But in AWS I cant do that as it is not supported.
How do I rewrite in AWS to my app for my domain.
Update
domain screen now
you could add a A record on your provider (route53, GoDadddy, NameCheap ...) to point myapp.mydomain.com on your ec2 instance.
On the ec2 instance you would need to run apache to listen on port 80 and forward to your app server the requests.
Otherwise you need to change your current A record on domain.com to point to your ec2 IP address and not the S3 bucket

Elastic Load Balancer Redirects to ELB Domain Name (Instead of keeping custom domain)

I'm not sure what I'm missing here and I am banging my head against a wall.
I would like to point my domain to a Cloudfront distribution that has an ELB origin. I have that, it is great and dandy, but all of my requests are being redirected from www.foo.com to the CNAME of the load balancer.
Is it possible to put CloudFront in front of ELB and keep a pretty domain name?
Thanks!

Resources