Skip to content

Add a health check URL for AWS ELB ECS

Alex Agranov edited this page Feb 14, 2017 · 2 revisions

One of the common problems encountered when deploying under AWS ECS/ELB is allowing a Target Group health check to succeed - especially if we're forcing all HTTP traffic to HTTPS, causing an infinite redirect loop.

An Nginx solution is to add a server block configuration that listens on a path such as /elb-status, irrespective of the port that traffic arrives on.

Here is how we can add such a server block proxy-wide, such that it is evaluated before any VIRTUAL_HOST/port-specific settings:

RUN { \
      [ COPY TEMPLATE SETTINGS HERE ]
      echo ' '; \
      echo 'server {'; \
      echo '  location /elb-status {'; \
      echo '    access_log off;'; \
      echo '    return 200;'; \
      echo '  }'; \
      echo '}'; \
    } > /etc/nginx/proxy.conf

The [ COPY TEMPLATE SETTINGS HERE ] is a reminder to follow the instructions in the NOTE under "Replacing default proxy settings" in the Readme.