server {
  listen 80 default_server;

  location /__varnish_check__ {
    # This is the varnish upstream defined in the www.gov.uk vhost
    proxy_pass http://varnish;
  }

  <%- if scope.lookupvar('::aws_migration') %>
  # Send the Strict-Transport-Security header
  include /etc/nginx/add-sts.conf;
  # Required for L7 ALB
  location = /_healthcheck {
    return 200;
  }
  <%- end %>
  location / {
    return 444;
  }
}

<% unless scope.lookupvar('::aws_migration') %>
server {
  listen              443 default_server ssl;
  ssl_certificate     /etc/nginx/ssl/www.gov.uk.crt;
  ssl_certificate_key /etc/nginx/ssl/www.gov.uk.key;
  include             /etc/nginx/ssl.conf;

  location /__varnish_check__ {
    # This is the varnish upstream defined in the www.gov.uk vhost
    proxy_pass http://varnish;
  }

  location / {
    return 444;
  }
}
<%- end %>

server {
  listen 80 default_server;

  location /__varnish_check__ {
    # This is the varnish upstream defined in the www.gov.uk vhost
    proxy_pass http://varnish;
  }

  <%- if scope.lookupvar('::aws_migration') %>
  # Health checks from ALB reuse Fastly __canary__ health check path
  # and bypass authentication on Integration
  location /_healthcheck_www {
    proxy_pass http://varnish/__canary__;
  }
  location /_healthcheck_www-origin {
    proxy_pass http://varnish/__canary__;
  }
  location /_healthcheck_assets-origin {
    return 200;
  }

  # Send the Strict-Transport-Security header
  include /etc/nginx/add-sts.conf;
  # Required for L7 ALB
  location = /_healthcheck {
    return 200;
  }
  <%- end %>
  location / {
    return 444;
  }
}

<% unless scope.lookupvar('::aws_migration') %>
server {
  listen              443 default_server ssl;
  ssl_certificate     /etc/nginx/ssl/www.gov.uk.crt;
  ssl_certificate_key /etc/nginx/ssl/www.gov.uk.key;
  include             /etc/nginx/ssl.conf;

  location /__varnish_check__ {
    # This is the varnish upstream defined in the www.gov.uk vhost
    proxy_pass http://varnish;
  }

  location / {
    return 444;
  }
}
<%- end %>

Add Cache ALB health check path
Add Cache ALB health check path

Define location paths for application health checks from the public ALB.

We want to add the instance to the ALB `www` target group when Nginx, Varnish and
Router are up. We can achieve this with the `__canary__` endpoint. This endpoint
is not cached in Varnish.

`assets` traffic will be available as soon as Nginx is healthy.
