Cloudfront distribution does not work with for an EC2 instance

I'm using an EC2 instance (AWS) to run my server. I've been testing out a few things and want my website and server domains to be HTTPS for a cookie related issue. I was able to add my website (hosted on S3 as of now) on cloudfront to get a secure domain. I tried to do the same with my server URL. However My server is not working on the new Cloudfront URL. I have my webapp on Cloudfront and It's working completely fine on the new generated cloudfront URL.

Details:

  1. I have added the public IPv4 DNS to Cloudfront's origin Domain Name.
  2. The running server is a Node Server. So I try to access it by d7xxxxxxxxx.cloudfront.net:3001 (server is running on port 3001). (But does not respond)
  3. The security group is configured with all ports open. (So this should not be a problem I guess.)

Questions

  1. How can I get my server to work on Cloudfront? The URL is not responding. (The server is working when I access it by the EC2 public DNS).
  2. Is it fine to use the public DNS of the ec2 to connect it to cloudfront on temporary basis?

References

  1. Ref

Answers 1

  • So I try to access it by d7xxxxxxxxx.cloudfront.net:3001 (server is running on port 3001)

    You would only access the CloudFront distribution at ports 80 and 443. CloudFront doesn't mirror the ports of the origin server, it only serves the default ports for HTTP and HTTPS. You would configure port 3001 in your origin settings within CloudFront as the origin HTTP port.


Related Articles