I’m looking for guidance on setting up HTTPS communication from my AWS Application Load Balancer (ALB) to my backend NGINX servers hosted on EC2. I’ve successfully set up SSL termination for incoming connections at the ALB, but I now want to ensure that my traffic to the NGINX instances is also encrypted using a self-signed certificate.
Despite following AWS guidelines, I encounter 502 Bad Gateway errors when accessing the service, and I’m unsure where the issue lies. Here’s what I have checked so far:
- The security groups are set to allow traffic on port 443 between the ALB and the EC2 instances.
- VPC settings are configured properly since HTTP requests on port 80 are functioning fine.
- NGINX is set up to listen on port 443 for HTTPS and responds correctly when accessed directly.
- I have created a public key policy with my self-signed certificate.
- The backend authentication policy is properly established.
- Ensured the SSL negotiation policy is compatible with what I’ve configured in NGINX.
- My NGINX log files only show HTTP requests and not any HTTPS traffic.
What steps can I take to diagnose or troubleshoot this further? Are there other debugging techniques you would recommend?
Here’s the current configuration I have for my ALB:
aws elbv2 describe-load-balancers --names my-load-balancer
{
"LoadBalancers": [{
"LoadBalancerArn": "arn:aws:elasticloadbalancing:us-west-2:123456789:loadbalancer/app/my-load-balancer/abc",
"DNSName": "my-load-balancer-123456.us-west-2.elb.amazonaws.com",
"Type": "application",
"Scheme": "internet-facing",
"VpcId": "vpc-xyz987",
"State": {"Code": "active"},
"AvailabilityZones": [
{"ZoneName": "us-west-2a", "SubnetId": "subnet-xyz"},
{"ZoneName": "us-west-2b", "SubnetId": "subnet-abc"}
],
"SecurityGroups": ["sg-xyz987"]
}]
}
And here’s my NGINX virtual host setup:
server {
listen 443 ssl;
server_name mydomain.com;
root /var/www/html;
ssl_certificate /path/to/my.crt;
ssl_certificate_key /path/to/my.key;
ssl_protocols TLSv1.2;
ssl_ciphers HIGH:!aNULL:!MD5;
location / {
proxy_pass http://127.0.0.1:8080;
}
}
The following are the commands I ran to generate the necessary SSL certificate:
openssl genrsa -out /path/to/my.key 2048
openssl req -new -key /path/to/my.key -out /path/to/my.csr
openssl x509 -req -days 365 -in /path/to/my.csr -signkey /path/to/my.key -out /path/to/my.crt