ansible_role_nginx_vhosts

Configure nginx vhosts with Ansible

Build Status

Requirements

Nginx needs to be installed and configured, many vars and assumptions are tightly coupled with this nginx role. For Lets Encrypt support the certbot role is required.

See the full example for a complete playbook.

Example playbook

- hosts: all
  become: yes

  roles:
  - nginx
  - nginx-vhosts

  vars:
    nginx_vhosts:
    # static host serving the files under /var/www/example.com
    - host: example.com
      type: static
    # to proxy an upstream
    - host: proxy.example.com
      type: proxy # use type proxy-ws for websocket support
      target: http://localhost:3000
    # to proxy an upstream with dynamic IP
    - host: proxy.example.com
      type: proxy
      dynamic_target: http://example.local:3000
    # redirect to another domain
    - host: redirect.example.com
      type: redirect
      target: https://mysite.com
    # redirect to the www subdomain
    - host: example2.com
      type: redirect
      target: www
    # redirect to the domain without www
    - host: www.example.com
      type: redirect
      target: no-www
    # remove an upstream
    - host: www.example.com
      type: disabled
    # extra_conf can be added to all types
    - host: example.com
      type: static
      extra_conf: |
        client_max_body_size 50m;

Role variables

None of the variables below are required.

Variable Default Comment

For all options see defaults/main.yml

Development

You can use the Vagrantfile for local testing, just install vagrant and virtualbox and execute the following commands:

vagrant up
vagrant provision

TODO

  • locations support

License

MIT

About

Configures nginx vhosts

Install
ansible-galaxy install morbidick/ansible-role-nginx-vhosts
GitHub repository
License
Unknown
Downloads
42
Owner
mostly web dev, freelancer with @madways