Greg Miller
Greg Miller

Reputation: 1084

Cloudfront with EC2 instance

I was able to get Cloudfront working with an S3 instance, but I'm stuck with EC2 (I'm new to AWS). My Go server is accessible via elastic IP on port 443.

When creating the Cloudfront distribution, I used my EC2's public DNS (IPv4) as the Origin, HTTPS only, alternate domain names to the host zones I've defined in Route43, custom SSL certificate from Certificate Manager (which is issued). The status of the Cloudfront distribution is Deployed and State is enabled.

If I try to access the Cloudfront distribution by using the subdomain I've setup, and I simply get "Sever Not Found". If I try to access the Cloudfront distribution using the given Cloudfront domain name, I get "502 ERROR The request could not be satisfied. CloudFront attempted to establish a connection with the origin, but either the attempt failed or the origin closed the connection. "

Are there more steps I'm missing to the process? I thought I could use EC2 as an origin.

DNS with Route43, Domain registered through GoDaddy

Cloudfront domain name: d2yxz5aawjiy26.cloudfront.net

Subdomain: api.tranquility.app

Elastic IP: 35.182.112.85 running on port 443

EDIT: If it matters, I'm running docker with the app mapping port 443 to 8080 in docker-compose.

UPDATE: Perhaps something to do with https://docs.aws.amazon.com/acm/latest/userguide/acm-services.html and that I should use a load balancer for my ec2 instance.

Upvotes: 4

Views: 1850

Answers (1)

Greg Miller
Greg Miller

Reputation: 1084

I ended up taking an alternative route and used Elastic Beanstalk, then switched the Cloudfront origin to the URL of the Elastic Beanstalk instance. I've added an HTTPS listener on port 443 to the load balancer and out to port 80 on the instances of the Elastic Beanstalk. I was also missing the name servers that Route 53 gave me, since my DNS is with them but Domain is with GoDaddy - so I added the four NS records into GoDaddy from Route 53.

Upvotes: 2

Related Questions