From eaf4032bc0a5fe833b9a53372a3a55761d3c0573 Mon Sep 17 00:00:00 2001 From: Emilien Mantel Date: Fri, 9 Oct 2015 17:54:07 +0200 Subject: [PATCH] Fix jessie and add doc --- README.md | 44 ++++++++++++++++++- templates/etc/nginx/upstream/upstream.conf.j2 | 2 +- tests/test.yml | 2 +- vars/main.yml | 13 +++--- 4 files changed, 51 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 3ce8256..f10cb69 100644 --- a/README.md +++ b/README.md @@ -47,9 +47,11 @@ Socket: ### Vhost management +You can see many examples in: [tests/test.yml](tests/test.yml). + - `nginx_vhosts`: List of dict. A vhost has few keys. See bellow. -#### +#### Common - `name`: (M) List of domain used. The first occurence is the most important! - `template`: (M) template used to create vhost @@ -69,10 +71,48 @@ Socket: - `php`: PHP base template. Can work with many frameworks/tools. - `wordpress` - `dokuwiki` + - `proxy` Templates works as parent-child. -You can see many examples in: [tests/test.yml](tests/test.yml). +#### 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` Dependencies ------------ diff --git a/templates/etc/nginx/upstream/upstream.conf.j2 b/templates/etc/nginx/upstream/upstream.conf.j2 index 4fd7d21..7fedf6e 100644 --- a/templates/etc/nginx/upstream/upstream.conf.j2 +++ b/templates/etc/nginx/upstream/upstream.conf.j2 @@ -9,7 +9,7 @@ upstream {{ item.name }} { {% for server in item.servers %} - server {{ server.name }}{% for p in nginx_upstream_server_params if server[p.key] is defined %}{{ s(p.key, server[p.key] | default(p.default), p.is_bool | default(false), p.min_version | default('0.0.1')) }}{% endfor %}; + server {{ server.path }}{% for p in nginx_upstream_server_params if server[p.key] is defined %}{{ s(p.key, server[p.key] | default(p.default), p.is_bool | default(false), p.min_version | default('0.0.1')) }}{% endfor %}; {% endfor %} {% if item.params is defined and item.params is iterable %} {% for param in item.params %} diff --git a/tests/test.yml b/tests/test.yml index 78f65c9..71f199c 100644 --- a/tests/test.yml +++ b/tests/test.yml @@ -11,7 +11,7 @@ nginx_upstreams: - name: 'test' servers: - - name: '127.0.0.1:80' + - path: '127.0.0.1:80' max_conns: 150 weight: 10 down: false diff --git a/vars/main.yml b/vars/main.yml index 56c9d01..df6406a 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -16,9 +16,10 @@ nginx_upstream_server_params: default: 'configuration_error' - key: 'slow_start' default: 0 - - key: 'max_conns' - default: 0 - min_version: '1.5.9' - - key: 'resolve' - is_bool: true - min_version: '1.5.12' +# Nginx Plus only +# - key: 'max_conns' +# default: 0 +# min_version: '1.5.9' +# - key: 'resolve' +# is_bool: true +# min_version: '1.5.12'