By using AWS re:Post, you agree to the Terms of Use

How to connect a Lightsail instance to AWS CloudFront?

0

Hi, I want to know if is possible how to connect an Amazon Lightsail Instance to CloudFront.

Thanks.
Regards, Juan Balbuena.

6 Answers
0

Yes, that's definitely possible :) There are two things to consider in particular when setting this up.

First of all, you need to point your domain to CloudFront. You will want to set up a CNAME record in your DNS zone, pointing to the xyz.cloudfront.net address you get when creating the CloudFront distribution. The name of that record should be "www.example.com" if that's the domain you want to enable CloudFront on. Making example.com (without www) work as well could be a bit more tricky as you can't use a CNAME for technical reasons. Route 53 offers a way around this, but the DNS management in Lightsail is a simpler version of that service essentially. But you can always add an A record for example.com, pointing to your server IP address. Then your server can redirect those requests (additional configuration needed).

Secondly, CloudFront needs to contact your server on some address. You could add a second record to your DNS zone. This time you call it "origin.example.com" (or anything really), make it an A record, and point it to the server IP address.

answered 5 years ago
0

Pleas forgive my cross post ( https://forums.aws.amazon.com/thread.jspa?messageID=874055&#874055 )

What am I doing wrong? When I access https://www.example.com/ I am redirected to http://lighsail.example.com. ( note the loss of SSL and the annoying name change which isn't using cloudfront ).

Here's my configuration.
I'm NOT using lightsail DNS, rather I'm using Route 53.
I'm using a static IP from lightsail, let's say 34.34.34.35
Route 53 has an A record for www.example.com using an ALIAS to the cloudfront domain name: dxxxxxxx.cloudfront.net.
Route 53 has an A record for lightsail.example.com pointing to the lightsail static IP 34.34.34.35.
Cloudfront has an origin domain name of lightsail.example.com
Cloudfront Origin Protocol Policy is HTTP Only.
Cloudfront Alternate Domain Names is www.example.com
Cloudfront SSL Certificate is the one issued by Route53 for *.example.com.
Cloudfront Viewer Protocol Policy is Redirect HTTP to HTTPS.

Thanks for your time and expertise!

answered 4 years ago
0

Hi JuanBalbuena and thanks for choosing Lightsail!

Did the response from D. Svanlund answer your question? If not, can you give me some detail on what exactly you're trying to accomplish and what you mean by "connect" your Lightsail instance to CloudFront?

answered 4 years ago
0

Thanks for your response.

My question has not yet been answered.

Cloudfront is AWS's Content Distribution Network ( CDN ). Besides the traditional benefits of CDN I also want to use Cloudfront's ability to access AWS Certificate Manager SSL certificates. The problem I am having is when I access the CDN URL I am redirected to the lightsail instance. ( e.g. https://www.example.com/ redirects to http://lighsail.example.com/ ). I'm expecting https://www.example.com/ to use the SSL certificate configured in CloudFront and Certificate Manager and the CDN to deliver the content using SSL.

Thanks again for your time and expertise!

answered 4 years ago
0

Hi,

I have the same basic question: How to setup AWS cloudfront with lightsail? (in my case on a subdomain specifically for WordPress)

My lightsail (WordPress) server does not show up in the "Origin Domain Name" dropdown list when creating a new distribution. So what should I do? This description:https://aws.amazon.com/blogs/startups/how-to-accelerate-your-wordpress-site-with-amazon-cloudfront/ is not clear on that to me.

Using the servers fixed IP address as "Origin Domain Name" in cloudfront is not allowed. So I created a DNS record in Route 53 (wordpress.openinfo.nl) to point to the static IP of my lightsail server. And I added this DNS record as "Origin Domain Name" in cloudfront (also including a https certificate *.openinfo.nl). And I selected the cloudfront distribution as A record, type alias, in Route 53. The cloudfront Alternate Domain Names (CNAMEs) is service.openinfo.nl .

This solution does not work:

  1. The cloudfront distribution service.openinfo.nl does resolve the lightsail server but over http, it does not use the certificate I attached... Should I use redirect http to https?

  2. Also, if I click 'login' it redirects to "http://wordpress.openinfo.nl/wp-login.php" i.e. the DNS that I assigned for the purpose of orgin domain name to cloudfront. The WordPress "WP_SITEURL" and "WP_HOME" settings somehow automatically reflect the DNS wordpress.openinfo.nl.

  3. And also, the DNS name wordpress.openinfo.nl resolves the lightsail server (which I don't want). How to avoid this?

So I also tried creating the service.openinfo.nl as A record (DNS) in Route 53 pointing to the static IP of the WordPress lightsail server. But then I cannot create the same service.openinfo.nl as alias A record...

So I am stuck... Please advice? Many thanks in advance! Wouter

PS: openinfo.nl points to a cloudfront distribution with a certificate which points to a static site in a S3 buckets and works fine.

answered 4 years ago
0

I am having the same problem. I have a Lightsail instance set up in Canada Central. I have created a Distribution for the Instance. I have also verifild my registered domain names for use with Custom Domains (which I probably don't need to do as I don't care if the static content being served from Cloudfront reflects the domain of my website or not). When I go to Route 53 to create and "Alias to CloudFront Distribution" the only region available is 'US East (N. Virginia)" and I have "No resources found." in that region.

I am going nutz here. I have been working on this for days. Please help.

answered 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions