Diving into Trellis, Running a fresh unchanged config

The Nginx includes feature is for including conf files into your site’s Nginx conf here. I’m not aware of examples out there. I’ve used it once to include some redirects. I created a list variable like this in group_vars/all/main.yml:

redirects:
  - from: slugtoredirect
    to: http://othersite.com/newslug/
  - from: anotherslug
    to: http://someothersite.com/anotherslug

Then I created this template in roles/wordpress-setup/templates/includes.d/example.com/redirects.conf.j2:

# {{ ansible_managed }}

{% for item in redirects | default([]) %}
  location ~* /{{ item.from }}/? {
    return 301 {{ item.to }};
  }

{% endfor %}

You’ll be able to figure out anything you need with the example above, the Nginx docs, the Jinja templating docs, Ansible docs, and google. Enjoy.

1 Like