Add option "nginx_extra_log_formats" to setup multiple log formats in nginx.conf.

This commit is contained in:
Stefan Hornburg (Racke) 2021-01-09 15:24:49 +01:00
parent 3e0b830f84
commit c94717e020
No known key found for this signature in database
GPG Key ID: 5B93015BFA2720F8
3 changed files with 15 additions and 0 deletions

View File

@ -137,6 +137,15 @@ See the template in `templates/nginx.conf.j2` for more details on the placement.
Configures Nginx's [`log_format`](http://nginx.org/en/docs/http/ngx_http_log_module.html#log_format). options.
nginx_extra_log_formats:
- name: gzip
format: |-
'$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for" "$gzip_ratio"'
Additional log formats added to `nginx.conf` below the standard one.
nginx_default_release: ""
(For Debian/Ubuntu only) Allows you to set a different repository for the installation of Nginx. As an example, if you are running Debian's wheezy release, and want to get a newer version of Nginx, you can install the `wheezy-backports` repository and set that value here, and Ansible will use that as the `-t` option while installing Nginx.

View File

@ -88,3 +88,5 @@ nginx_log_format: |-
'$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"'
nginx_extra_log_formats: []

View File

@ -31,6 +31,10 @@ http {
log_format main {{ nginx_log_format|indent(23) }};
{% for format in nginx_extra_log_formats %}
log_format {{ format.name }} {{ format.format|indent(23) }};
{% endfor %}
access_log {{ nginx_access_log }};
sendfile {{ nginx_sendfile }};