Install nginx (naxsi version), add virtual hosts and provide ability to set settings for them.
Every task in this role have to be executed under root privileges, so use become: yes
(Ansible 2.x) or sudo: yes
(Ansible 1.x) on playbook level.
This role can manage most popular nginx usage scenarios:
- Nginx as main server, no requests send to any backends nor dynamic content generated. Nginx just serve static content
- Nginx as main server with php-fpm backend,
- Nginx as main server with apache2 backend, works as proxy
Below every scenario will be explained in details.
Prerequisites:
- Site should be already installed in some folder on your server.
- Disable any upstreams
- Setup virtual host
- Leave only php-fpm upstream
- Setup virtual host as folloing:
Ubuntu 14.04
This role support vhosts
variable. See it structure here. This role can add to every virtual hosts configuration key nginx
with following value:
vhosts: www.example.com: enabled: yes name: www.example.com aliases: - example.com root: /var/www nginx: template: {{ ansible_hostname }}/www.example.com.conf.j2
nginx: template: locations: settings: listen: