Nginx – AWS Elastick Beanstalk + Node JS + HTTPS = Connection Refused

amazon-web-serviceselastic-beanstalkhttpsnginxnode.js

I have a node js app deployed on AWS, using Elastic Beanstalk with a single instance. It works well with HTTP but I am having trouble setting up the HTTPS access.

I created my certificate and followed the instructions from the AWS EB doc: http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/https-singleinstance-nodejs.html

Here is a description of my issue after I deploy the new code:

I can still connect to the url on a browser using HTTP, however, when try connecting using HTTPS, I get the message ERR_CONNECTION_REFUSED

I used netcat to check if the port 443 is reachable, and it is not:

nc -z environment.elasticbeanstalk.com 80

returns:

Connection to environment.elasticbeanstalk.com port 80 [tcp/http] succeeded!

but

nc -z environment.elasticbeanstalk.com 443

returns nothing

I also checked the inbound rule for the security group associated with the EC2 instance, and it does have the port 443 open:
enter image description here

And finally, I checked the elastic beanstalk logs and could not find any reference to the HTTPS request. If I look for timestamps around the time when I try to access there app using HTTPS, there are none. It looks like the nginx server never received the request.

I didn't have any problem setting up similar HTTPS access when I was using Elatstic Beanstalk with php/apache server, but in this case I am new to node/nginx so I may miss something basic.

Do you have any suggestion on what I could check or what I could do?

Thank you very much in advance,

Erez

Best Answer

Ok I found the issue: in the elastic beanstalk configuration, the proxy was not setup.

I updated the EB configuration to include the nginx proxy and it worked.

Configuration > Software Configuration > Container Options > Proxy server: nginx
Related Topic