0

First time here but have used help from here a lot.

I managed to find some answers from this thread Cloudfront and EC2

But as it is mentioned in answer, this issue is happening for me

“Be sure, when you connect through CloudFront, that the server doesn't redirect you back to the EC2 hostname or IP (the address bar in the browser will change, if it does, and you'll want to fix your web server's config if that happens).”

So for this do I need to change anything on httpd.conf? Or ec2’s firewall? I am using amazon AMI with LAMP

Thanks Pramit

Pramit J
  • 11
  • 2

1 Answers1

0

It means that when your application points to another page in the app (eg index.html pointing to about.html), you should use relative references (/about.html rather than http://1.2.3.4/about.html).

This way, traffic coming in through CloudFront will continue to come in through CloudFront rather than be redirected elsewhere.

Update:

Let's say your configuration is:

  • A single Amazon EC2 instance with an Elastic IP address
  • A CloudFront distribution
  • Your own domain name that you'd like to point to CloudFront

In this case, you would:

  • Configure a CNAME record (eg www.example.com) on your Domain (on Route 53 or your DNS provider) to point to the CloudFront distribution URL
  • Configure Alternate Domain Names (CNAMEs) in CloudFront with your CNAME (www.example.com) -- this is so that it knows what domain name is being used to send requests to CloudFront
  • Set origin to the Elastic IP address of your EC2 instance -- this is where CloudFront obtains the information that it should cache and serve
  • If you want CloudFront to fetch data from a sub-path (sub-directory) of the origin, then set origin path to that path. For example, you might want to serve content from /dev or /prod.

See: Values That You Specify When You Create or Update a Web Distribution - Amazon CloudFront

John Rotenstein
  • 241,921
  • 22
  • 380
  • 470
  • Thank you, Only redirect I have is on .htaccess for http to https Also on cloudfront setup, origin should be my domain name or public dns of ec2? I am little confused between origin, origin path and Alternate Domain Names (CNAMEs) – Pramit J Apr 27 '18 at 12:31