I am trying to setup CloudFront with an Amazon S3 static website and Amazon EC2 nodejs server.
I have followed the following steps:
- Setup S3 bucket
example.com - Create certificate in ACM issued at
example.comandapi.example.com - Create CloudFront distribution
- Set created CloudFront alternate domain names to:
example.comandapi.example.com - Added SSL certificate from ACM
- Created origin with
example.com.s3-website-AWS_REGION.amazonaws.com - In Route 53, added entry for
example.comandapi.example.comwith alias name pointing to CloudFront distribution.
After this my https://example.com is loading the webpage correctly. Now I try to set CloudFront for my nodejs server as well.
Added new origin in CloudFront distribution with
ec2-IP.AWS_REGION.compute.amazonaws.com.Added the behaviors for pattern
api.example.com/*with all TTL set to zero.
Now when I try to access the nodejs server using https://api.example.com, I am not able to do so and get error. I am not sure what I am doing wrong.