I am currently learning about AWS and I have a single EC2 instance running with a nodejs server on port 3000, an Application load balancer
with SSL setup that listen on port 80
and 443
(http & https). When I make requests to the http route it returns back the successful health check message. But when I try to access my api via the https method, I get a 502 Error
. I googled around and read some articles and they pointed out that the nodejs server keepAliveTimeout
and headersTimeout
should be higher than the timeout option of the ALB. I tried that and it didn't work. I also tried to set the max-http-header-value
to 16384
, I also tried to check the access logs for the load balancer on my S3 bucket and the logs just showed that I am getting a 502 error and nothing more. What could be the issue? Because I have tried all solutions that presented but they don't seem to work.
CodePudding user response:
The 443 listener needs to be pointed to port 80 on the ec2 instance
CodePudding user response:
The first thing to check is that your server is responding to requests. Try connecting to port 3000 on the server, either from the server itself (eg curl localhost:3000
) or from outside the server (which will require the Security Group to permit access to port 3000).
Once you have confirm that the server is responding, configure Security Groups as:
- A Security Group on the Application Load Balancer (
ALB-SG
) that permits Inbound access on ports 80 and 443 - A Security Group on the Amazon EC2 instance (
App-SG
) that permits inbound access on port 3000 fromALB-SG
That is, App-SG
should specifically refer to ALB-SG
in its Inbound rules.
Then, configure the Load Balancer to have a Target Group that points at port 3000 on the app server and provide it a URL for the Health Check (that could simply be /
).
Then, connect to the Application Load Balancer and see whether you can access your app.