Skip to content

Commit

Permalink
Fix jessie and add doc
Browse files Browse the repository at this point in the history
  • Loading branch information
Emilien Mantel committed Oct 9, 2015
1 parent 63fee94 commit eaf4032
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 10 deletions.
44 changes: 42 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
------------
Expand Down
2 changes: 1 addition & 1 deletion templates/etc/nginx/upstream/upstream.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
Expand Down
2 changes: 1 addition & 1 deletion tests/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 7 additions & 6 deletions vars/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'

0 comments on commit eaf4032

Please sign in to comment.