AcroMedia / ansible-role-virtual-host

Configure NGINX + PHP + SSL for a virtual host across it's complete life cycle from staging to production to decommission
GNU General Public License v3.0
0 stars 3 forks source link

nginx_aliases is a lie #2

Closed dale-c-anderson closed 3 years ago

dale-c-anderson commented 4 years ago

I've run into a couple edge cases now where the built in virtual host templates had no hope of supporting it, which required me brewing my own nginx config.

In all cases, the issue was with server names not being flexible enough in terms of how redirects are handled. The "nginx_aliases" variable is currently a lie; they're not aliases, they're redirects. We actually need both aliases AND redirects.

Requirements

Things that will need updating

Ideal outcomes

Complex example:

       nginx_server_names:
          - name: project.server.example.com
            type: primal
            aliases:
              - name: en.project.server.example.com
              - name: fr.project.server.example.com

          - name: www.bigcorp.com
            type: canonical
            aliases:
              - name: en.bigcorp.com
              - name: fr.bigcorp.com

          - name: bigcorp.com
            type: redirect
            target_name: www.bigcorp.com
            aliases:
              - name: www.oldname.com
              - name: oldname.com

Normal use case:

       nginx_server_names:
          - name: project.server.example.com
            type: primal

          - name: www.bigcorp.com
            type: canonical

          - name: bigcorp.com
            type: redirect
            target_name: www.bigcorp.com