0

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.

  • You've identified the problem -- "Connection Refused" on port 80 -- but there isn't enough information here to help you solve the problem. – womble Jun 30 '17 at 00:51
  • That's the issue, the access and error logs are empty, the security groups are allowing all traffics, the elb listeners are listening to port 80, the nginx is listening on port 80. I went through everything I could think of and still didn't figure it out, so I'm hoping any suggestions from others could help since it's probably something I missed. – NightwareSystems Jun 30 '17 at 01:23
  • Port 3000 (apparently) isn't nginx, so the ability to connect there doesn't give any new information. It sounds as though it may not be running all. If `ps auwwx | grep [n]ginx` returns nothing... then it isn't. – Michael - sqlbot Jun 30 '17 at 03:13
  • The 3000 port is the one nodejs app is running on, I tested on it to confirm the EC instance is reachable, which narrowed the issue to nginx itself. This is the result of the command you provided, it seems to give results? Sorry I'm not an expert on Linux. http://prntscr.com/fpuv5c – NightwareSystems Jun 30 '17 at 03:51

0 Answers0