added support for includes and auths, extended docu
This commit is contained in:
parent
b1b10fad9b
commit
1ec6fbb1fd
8 changed files with 58 additions and 7 deletions
25
README.md
25
README.md
|
|
@ -23,6 +23,9 @@ upstreams: {}
|
||||||
# name: *vhostconfig*, see below for definition
|
# name: *vhostconfig*, see below for definition
|
||||||
vhosts: {}
|
vhosts: {}
|
||||||
|
|
||||||
|
# name: *mapsconfig*, see below for definition
|
||||||
|
maps: {}
|
||||||
|
|
||||||
# force all traffic on ssl, except letsencrypt challenges
|
# force all traffic on ssl, except letsencrypt challenges
|
||||||
force_ssl: True
|
force_ssl: True
|
||||||
|
|
||||||
|
|
@ -76,6 +79,12 @@ custom: []
|
||||||
# array of locations, see below
|
# array of locations, see below
|
||||||
locations: [*locationconfig*, .. ]
|
locations: [*locationconfig*, .. ]
|
||||||
|
|
||||||
|
# array of files to include at the server level
|
||||||
|
includes: []
|
||||||
|
|
||||||
|
# configure authentication, disabled by default. See *authconfig* below for definition
|
||||||
|
auth: *authconfig*
|
||||||
|
|
||||||
# array of headers to add on this vhost
|
# array of headers to add on this vhost
|
||||||
add_headers: []
|
add_headers: []
|
||||||
```
|
```
|
||||||
|
|
@ -89,6 +98,22 @@ match: ''
|
||||||
alias: None
|
alias: None
|
||||||
```
|
```
|
||||||
|
|
||||||
|
**authconfig**
|
||||||
|
```
|
||||||
|
# Boolean: enable authentication
|
||||||
|
enabled: False
|
||||||
|
|
||||||
|
# Path to a htpasswd file
|
||||||
|
path :''
|
||||||
|
|
||||||
|
# can be 'all' or 'any'
|
||||||
|
satisfy: 'all
|
||||||
|
```
|
||||||
|
|
||||||
|
**mapsconfig**:
|
||||||
|
```
|
||||||
|
```
|
||||||
|
|
||||||
**phpconfog**:
|
**phpconfog**:
|
||||||
```
|
```
|
||||||
ini:
|
ini:
|
||||||
|
|
|
||||||
|
|
@ -5,11 +5,11 @@ nginx:
|
||||||
"127.0.0.1": {}
|
"127.0.0.1": {}
|
||||||
"::1": {}
|
"::1": {}
|
||||||
monitoring: true
|
monitoring: true
|
||||||
serverpki: true
|
|
||||||
php: false
|
php: false
|
||||||
force_ssl: true
|
force_ssl: true
|
||||||
upstreams: {}
|
upstreams: {}
|
||||||
vhosts: {}
|
vhosts: {}
|
||||||
|
maps: {}
|
||||||
resolver:
|
resolver:
|
||||||
- 8.8.8.8
|
- 8.8.8.8
|
||||||
- 8.8.4.4
|
- 8.8.4.4
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ http {
|
||||||
reset_timedout_connection on;
|
reset_timedout_connection on;
|
||||||
|
|
||||||
server_names_hash_bucket_size 64;
|
server_names_hash_bucket_size 64;
|
||||||
|
map_hash_bucket_size 64;
|
||||||
# server_name_in_redirect off;
|
# server_name_in_redirect off;
|
||||||
|
|
||||||
include /etc/nginx/mime.types;
|
include /etc/nginx/mime.types;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
---
|
---
|
||||||
dependencies:
|
dependencies:
|
||||||
- { role: monitoring, when: nginx.monitoring }
|
- { role: monitoring, when: nginx.monitoring }
|
||||||
- { role: x509certs }
|
|
||||||
- certificates
|
- certificates
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,13 @@
|
||||||
notify:
|
notify:
|
||||||
- restart nginx
|
- restart nginx
|
||||||
|
|
||||||
|
- name: execute maps template
|
||||||
|
template:
|
||||||
|
src: maps.conf.j2
|
||||||
|
dest: /etc/nginx/conf.d/maps.conf
|
||||||
|
notify:
|
||||||
|
- restart nginx
|
||||||
|
|
||||||
- name: create nginx vhosts
|
- name: create nginx vhosts
|
||||||
template:
|
template:
|
||||||
src: vhost.conf.j2
|
src: vhost.conf.j2
|
||||||
|
|
|
||||||
10
templates/maps.conf.j2
Normal file
10
templates/maps.conf.j2
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
{% for map in nginx.maps %}
|
||||||
|
{% set m = nginx.maps[map] %}
|
||||||
|
# {{ map }}
|
||||||
|
map ${{ m.source }} ${{ m.destination }} {
|
||||||
|
{% for i in m.data %}
|
||||||
|
'{{ i }}' '{{ m.data[i] }}';
|
||||||
|
{% endfor %}
|
||||||
|
}
|
||||||
|
|
||||||
|
{% endfor %}
|
||||||
|
|
@ -1,8 +1,6 @@
|
||||||
{% if nginx.serverpki %}
|
|
||||||
# certs sent to the client in SERVER HELLO are concatenated in ssl_certificate
|
# certs sent to the client in SERVER HELLO are concatenated in ssl_certificate
|
||||||
ssl_certificate /etc/ssl/{{ inventory_hostname }}.crt;
|
ssl_certificate /etc/ssl/{{ inventory_hostname }}.crt;
|
||||||
ssl_certificate_key /etc/ssl/private/{{ inventory_hostname }}.key;
|
ssl_certificate_key /etc/ssl/private/{{ inventory_hostname }}.key;
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
# verify chain of trust of OCSP response using Root CA and Intermediate certs
|
# verify chain of trust of OCSP response using Root CA and Intermediate certs
|
||||||
ssl_trusted_certificate /etc/ssl/certs/ca-certificates.crt;
|
ssl_trusted_certificate /etc/ssl/certs/ca-certificates.crt;
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ server {
|
||||||
proxy_pass {{ vhost.backend }};
|
proxy_pass {{ vhost.backend }};
|
||||||
|
|
||||||
# add proxy headers
|
# add proxy headers
|
||||||
proxy_set_header Host $host;
|
proxy_set_header Host {% if 'host' in vhost %}"{{ vhost.host }}"{% else %}$host{% endif %};
|
||||||
proxy_set_header X-Real-IP $remote_addr;
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
proxy_set_header X-Forwarded-Proto $scheme;
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
|
|
@ -61,8 +61,19 @@ server {
|
||||||
}
|
}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
|
{% if vhost.auth.enable|default(False) %}
|
||||||
|
auth_basic "restricted area";
|
||||||
|
auth_basic_user_file {{ vhost.auth.path }};
|
||||||
|
satisfy {{ vhost.auth.satisfy|d('all') }};
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
|
||||||
|
{% for include in vhost.includes|default([]) %}
|
||||||
|
include {{ include }};
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
{% if vhost.letsencrypt|d(False) %}
|
{% if vhost.letsencrypt|d(False) %}
|
||||||
ssl_certificate /etc/ssl/nginx_{{ vhost_name }}.chain.crt;
|
ssl_certificate /etc/ssl/nginx_{{ vhost_name }}.chain.crt;
|
||||||
ssl_certificate_key /etc/ssl/private/nginx_{{ vhost_name }}.key;
|
ssl_certificate_key /etc/ssl/private/nginx_{{ vhost_name }}.key;
|
||||||
{% endif %}
|
{% endif %}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue