1

I am trying to serve my node js API (deployed on AWS EC2 and attached with application load balancer) through cloudfront url, is it possible?

Here are the steps I followed so far -

  1. Created S3 bucket to host static website hosting
  2. Created cloudfront distribution and linked S3 bucket with it. I can access S3 bucket contents with default url generated from cloudfront
  3. Created custom origin for node js instance
  4. Created behavior "api/*" to access node js API through cloudfront.

But when I am trying to access API with following url -

http://d3m30a4naen9t2.cloudfront.net/api/getItems

it throws "not found", it's not 404, this response is from EC2 server however the specified route exists.

Can anyone help please?

1 Answer 1

0

I am using ELB. I deployed my code which is on node.js, and everything is working fine. I was facing a lots of problem in ELB but finally we came to stable stage. If you want to serve your APIs then first use SSL which has lesser protocols in other words, use less secure SSL otherwise, your API will not be able to hit from any other source. Simply deploy your code through git or directly from filezilla and run the command on both servers (primary and secondary) as pm2 start index.js/server.js or whatever your main express file is.

Suggestion: Please be careful while selecting security certificates, because on ELB, if you do not follow the correct implementation, you will definitely face the problem of "API not accessible" or "Remote server is unable to connect".

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.