Roots Discourse

NGINX Child Template to Accept Uknown Hosts

I have a Trellis site set up on AWS (ELB, EC2, RDS). Our health checks are failing because hitting the site IP directly returns a 502.

I believe I need to overwrite the NGINX config to accept unknown hosts to make this work correctly. Has anyone ever run into an issue like this?

Trellis includes two nginx configs no-default.conf.j2 and ssl.no-default.conf.j2 to

Drop requests for unknown hosts

They are listed for inclusion in main.yml:

Thanks for the response. I don’t think I exactly understand what those configs are set to do though, seems like they’re attempting block unknown hosts, whereas I want to wildcard accept any.

For future reference of anyone, I was able point the IP addresses by adding them to the redirects list under site_hosts in wordpress_sites.yml, even though the docs say you can’t, ie:

site_hosts:
      - canonical: domain.com
        redirects:
          - www.domain.com
          - 55.555.55.555

Here is what I used on AWS ALB:

    site_hosts:
      - canonical: example.com # Useless, just make it easier for human to see which site is it
      - canonical: _ # Important for AWS Application Load Balancer

See: https://nginx.org/en/docs/http/server_names.html

You also need to set up some health check endpoints for ALB as well. I generate it during deploy:

project_templates:
  - name: .env config
    src: roles/deploy/templates/env.j2
    dest: .env
  - name: health-check.php for AWS ALB
    src: roles/aws-alb/templates/health-check.php.j2
    dest: web/health-check.php
<?php
// roles/aws-alb/templates/health-check.php.j2
// {{ ansible_managed }}
echo 'one apple a day keeps the doctor away';
2 Likes