0

I deployed my NodeJS/Express app on AWS Beanstalk. The current config is :

Environment type: single instance
EC2 instance type: t2.micro
Node.js version: 10.15.0
No load balancer
Proxy server : Nginx

When deployed it gives me a URL http://<app-name>.<server-location>.elasticbeanstalk.com/

I tested (using Postman) my authenticate API with the URL - http://<app-name>.<server-location>.elasticbeanstalk.com/users/authenticate and it gives me the status code of 200 OK and is working fine.

When I use HTTPS instead of HTTP it doesn't work as expected. In postman I get below error:

There was an error connecting to https://<app-name>.<server-location>.elasticbeanstalk.com/users/authenticate

I have my frontend deployed on netlify and when I trigger the same request from my Web application it gives me below error :

The page at 'https://<app-name>.netlify.com/login' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://<app-name>.<server-location>.elasticbeanstalk.com/users/authenticate'. This request has been blocked; the content must be served over HTTPS.

I understand that since my request is coming from https I need to have my backend configured to have https listener. I am not sure as to how I can accomplish this in AWS Beanstalk where I don't have a Load balancer and my env type is a single instance.

I am new to AWS. Appreciate your help. Thanks!

Shantanu Tomar
  • 1,572
  • 7
  • 38
  • 64

1 Answers1

0

You'll need to add an .ebextension config file to:

  • Allow 443 traffic in your Security Group
  • Install the ssl package
  • copy the certificates from the application package to the ssl dir. (certificates can be created in the certificate manager) or paste them in the config file
  • edit nginx config

Here is an example https://edwardsamuel.wordpress.com/2015/07/17/enable-https-and-http-redirect-on-aws-elastic-beanstalk/