I'm having the issue with ELB constantly showing unhealthy instance. The access.log
and error.log
are both empty, which makes it seem the ELB is not able to reach the EC2 instance at all. For the sake of testing, I'm using security groups that allow All Traffic
to make sure it's not it's not security groups problem on both the ELB and EC2 instance.
Below is the nginx.conf file I'm using with .ebextensions, it's being created properly as I see it in the /etc/nginx/conf.d/00_elastic_beanstalk_proxy.conf
. The ELB test is on HTTP Port 80 /elb-health-check
container_commands:
00-copy-my-nginx-config:
command: "sudo cp /tmp/my-custom-nginx.conf
/tmp/deployment/config/#etc#nginx#conf.d#00_elastic_beanstalk_proxy.conf"
01-delete-my-nginx-config:
command: "sudo rm /tmp/my-custom-nginx.conf"
files:
"/tmp/my-custom-nginx.conf":
mode: "000644"
owner: root
group: root
content: |
server
{
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
# Don't redirect the health check for ELB
location /elb-health-check
{
access_log off;
return 200;
}
}
server
{
listen 80;
server_name example.com;
root /var/app/current/public;
# Redirect to HTTPs
if ($http_x_forwarded_proto = "http")
{
return 301 https://$host$request_uri;
}
# API requests to server
location /
{
proxy_pass http://localhost:3000/;
}
}
I tried connecting to the server directly on port 80, it gives me a Connection Refused
error, but when I connect on port 3000, it works fine, so I'm suspecting the issue would be with nginx not allowing any requests to come in.
The listeners on the ELB are HTTP 80 -> HTTP 80, HTTPs 443 -> HTTP 80, the SSL is being handled on the ELB using Amazon certificate.
Any suggestions would be highly appreciated, thanks.