diff --git a/README.md b/README.md index 86e6d7b..5fe5924 100644 --- a/README.md +++ b/README.md @@ -81,6 +81,12 @@ The user under which Nginx will run. Defaults to `nginx` for RedHat, `www-data` Configuration of the default error and access logs. Set to `off` to disable a log entirely. + nginx_access_logs: + - "/var/log/nginx/myformat1.log myformat1 buffer=16k" + - "/var/log/nginx/myformat2.log myformat2 buffer=16k" + +Configuration of the additional access logs. + nginx_sendfile: "on" nginx_tcp_nopush: "on" nginx_tcp_nodelay: "on" @@ -137,6 +143,18 @@ 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_log_formats: + myformat1: |- + '$remote_addr - $remote_user [$time_local] "$request" ' + '$status $body_bytes_sent "$http_referer" ' + '"$http_user_agent" "$http_x_forwarded_for"' + myformat2: |- + '$remote_addr - $remote_user [$time_local] "$request" ' + '$status $body_bytes_sent "$http_referer" ' + '"$http_user_agent" "$http_x_forwarded_for"' + +Configures additional log format [`log_format`](http://nginx.org/en/docs/http/ngx_http_log_module.html#log_format). options. + 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. diff --git a/defaults/main.yml b/defaults/main.yml index 0509dbe..9e9dc0a 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -25,6 +25,7 @@ nginx_multi_accept: "off" nginx_error_log: "/var/log/nginx/error.log warn" nginx_access_log: "/var/log/nginx/access.log main buffer=16k flush=2m" +nginx_access_logs: [] nginx_sendfile: "on" nginx_tcp_nopush: "on" @@ -88,3 +89,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_log_formats: {} diff --git a/templates/nginx.conf.j2 b/templates/nginx.conf.j2 index 7cdec60..1848ddc 100644 --- a/templates/nginx.conf.j2 +++ b/templates/nginx.conf.j2 @@ -31,7 +31,14 @@ http { log_format main {{ nginx_log_format|indent(23) }}; + {% for format_name, format in nginx_log_formats.iteritems() -%} + log_format {{ format_name }} {{ format | indent(23) }}; + {% endfor %} + access_log {{ nginx_access_log }}; + {% for access_log in nginx_access_logs -%} + access_log {{ access_log }}; + {% endfor %} sendfile {{ nginx_sendfile }}; tcp_nopush {{ nginx_tcp_nopush }};