ansible-nginx/README.md

145 lines
4.2 KiB
Markdown
Raw Normal View History

2015-07-16 16:44:25 +07:00
Nginx for Debian Ansible role
=============================
2015-07-15 17:14:39 +07:00
2015-12-01 21:52:10 +07:00
[![Ansible Galaxy](http://img.shields.io/badge/ansible--galaxy-HanXHX.nginx-blue.svg)](https://galaxy.ansible.com/list#/roles/4399) [![Build Status](https://travis-ci.org/HanXHX/ansible-nginx.svg?branch=master)](https://travis-ci.org/HanXHX/ansible-nginx)
2015-08-04 17:40:54 +07:00
2015-07-31 17:28:25 +07:00
Install and configure Nginx on Debian.
2015-10-22 20:46:21 +07:00
SSL management will come later.
2015-07-15 17:14:39 +07:00
Requirements
------------
2015-07-16 16:44:25 +07:00
None.
2015-07-15 17:14:39 +07:00
Role Variables
--------------
2015-07-16 16:44:25 +07:00
- `nginx_apt_package`: APT nginx package (try: apt-cache search ^nginx)
- `nginx_root`: root directory where you want to have your files
- `nginx_log_dir`: log directory (if you change it, don't forget to change logrotate config)
- `nginx_ssl_dir`: directory where you install your SSL/TLS keys
- `nginx_resolver`: list of DNS resolver (default: OpenDNS)
- `nginx_error_log_level`: default log level
- `nginx_dh_length`: DH key length (default is 2048)
### PHP
- `nginx_php`: boolean if you need to preconfigure PHP (default: false)
- `nginx_php_sockets`: list of //sockets//
You should see [Nginx upstream module doc](http://nginx.org/en/docs/http/ngx_http_upstream_module.html).
Socket:
- `unix_socket`
- `host`
- `port`
- `weight`
- `max_fails`
- `fail_timeout`
### Nginx Configuration
- `nginx_user`
- `nginx_worker_processes`
- `nginx_events`: key/value in events block
- `nginx_http`: key/value in http block
2015-11-03 20:44:14 +07:00
- `nginx_pid`: daemon pid file
2015-07-16 16:44:25 +07:00
### Vhost management
2015-10-09 22:54:07 +07:00
You can see many examples in: [tests/test.yml](tests/test.yml).
2015-07-31 17:28:25 +07:00
- `nginx_vhosts`: List of dict. A vhost has few keys. See bellow.
2015-10-09 22:54:07 +07:00
#### Common
2015-07-31 17:28:25 +07:00
- `name`: (M) Domain or list of domain used.
2015-12-01 21:46:57 +07:00
- `template`: (D) template used to create vhost. Optional if you set `delete` to true or using `redirect_tor`.
2015-07-31 17:28:25 +07:00
- `enable`: (O) Enable the vhost (default is true)
- `delete`: (O) Delete the vhost (default is false)
2015-09-09 22:44:53 +07:00
- `redirect_from`: (O) Domain list to redirect to the first `name`. You can use this key to redirect non-www to www
2015-12-01 21:46:57 +07:00
- `redirect_to`: (O) Redirect (302) all requests to this domain. Please set scheme (http:// or https:// or $sheme).
2015-09-09 22:44:53 +07:00
- `location`: (O) Add new custom locations (it does not overwrite!)
- `more`: (O) Add more custom infos.
- `upstream_params`: (O) Add upstream params (useful when you want to pass variables to PHP)
- `override_try_files`: (O) overrides default try\_files defined in template
2015-10-19 14:39:51 +07:00
- `manage_local_content`: (O) Boolean. Set to false if you don't want to manage local content (images, css...). This option is useless if you use proxy `template`
2015-07-31 17:28:25 +07:00
2015-12-01 21:46:57 +07:00
(O): Optional
(M): Mandatory
(D): Depends other keys...
2015-07-31 17:28:25 +07:00
#### Templates
2015-07-16 16:44:25 +07:00
2015-07-31 17:28:25 +07:00
- `base`: static template
- `dokuwiki`
- `phalcon`: Phalcon PHP Framework
- `php`: PHP base template. Can work with many frameworks/tools
- `php_index`: Same as above. But you can only run index.php
2015-10-09 22:54:07 +07:00
- `proxy`
- `wordpress`
2015-07-16 16:44:25 +07:00
2015-07-31 17:28:25 +07:00
Templates works as parent-child.
2015-07-16 16:44:25 +07:00
2015-10-09 22:54:07 +07:00
#### About proxy template
Proxy template allow you to use Nginx as reverse proxy. Usefull when you have application serveur such as Redmine, Jenkins...
You have many key added to vhost key:
- `upstream_name`: (O) upstream name used to pass proxy
- `proxy_params`: (M) list of raw params passed to the vhost
(O) : Optional
(M) : Mandatory
### Upstream management
- `nginx_upstreams`: List of dict. An upstream has few keys. See bellow.
Note: Few params are unavailable on old Nginx version. But this role don't put it if your version is too old!
#### Upstream params
- `name`: upstream name. Can be use in vhost with *proxy_pass http://upstream_name*
- `params`: list of param (hash, zone...)
- `servers`: each upstream MUST have at least 1 server
#### Server params
You must set a `path`. For example: *192.168.0.50:8080* or *unix:/tmp/my.sock*.
All this params are optional. You should see [Nginx upstream doc](http://nginx.org/en/docs/http/ngx_http_upstream_module.html).
- `weight`
- `max`fails`
- `fail`timeout`
- `backup`
- `down`
- `route`
- `slow`start`
2015-07-15 17:14:39 +07:00
Dependencies
------------
2015-07-16 16:44:25 +07:00
None
2015-07-15 17:14:39 +07:00
Example Playbook
----------------
- hosts: servers
roles:
2015-07-16 16:44:25 +07:00
- { role: HanXHX.nginx }
2015-07-15 17:14:39 +07:00
License
-------
2015-07-16 16:44:25 +07:00
GPLv2
2015-07-15 17:14:39 +07:00
Author Information
------------------
2015-11-03 20:44:14 +07:00
- Twitter: https://twitter.com/hanxhx