andyceo.nginx
Ansible Role: nginx
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.
Nginx as static main server
Prerequisites:
- Site should be already installed in some folder on your server.
- Disable any upstreams
- Setup virtual host
Nginx as main server with php-fpm as backend
- Leave only php-fpm upstream
- Setup virtual host as folloing:
Nginx as main server proxy with apache2 backend
Requirements
Ubuntu 14.04
Variables
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:
Install nginx web server (nginx-naxsi), manage virtual hosts and settings for them
ansible-galaxy install andyceo.nginx