瀏覽代碼

add option to log nginx access to file

- the nginx access log wil be written to /matrix/nginx-proxy/access.log
- the log will not be forwarded to the systemd journal anymore
pull/213/head
Thomas Kuehne 6 年之前
父節點
當前提交
6220885e7d
共有 4 個文件被更改,包括 24 次插入0 次删除
  1. +3
    -0
      roles/matrix-nginx-proxy/defaults/main.yml
  2. +14
    -0
      roles/matrix-nginx-proxy/tasks/setup_nginx_proxy.yml
  3. +4
    -0
      roles/matrix-nginx-proxy/templates/nginx/nginx.conf.j2
  4. +3
    -0
      roles/matrix-nginx-proxy/templates/systemd/matrix-nginx-proxy.service.j2

+ 3
- 0
roles/matrix-nginx-proxy/defaults/main.yml 查看文件

@@ -25,6 +25,9 @@ matrix_nginx_proxy_container_additional_volumes: []
# A list of extra arguments to pass to the container
matrix_nginx_proxy_container_extra_arguments: []

# Controls whether nginx logs access to stdout of the container (and so to journald) or to the file /matrix/nginx-proxy/access.log
matrix_nginx_access_log_to_file: false

# Controls whether matrix-nginx-proxy should serve the base domain.
#
# This is useful for when you only have your Matrix server, but you need to serve


+ 14
- 0
roles/matrix-nginx-proxy/tasks/setup_nginx_proxy.yml 查看文件

@@ -115,6 +115,14 @@
daemon_reload: yes
when: "matrix_nginx_proxy_enabled and matrix_nginx_proxy_systemd_service_result.changed"

- name: Ensure Matrix nginx-proxy access.log file exist
file:
path: "{{ matrix_nginx_proxy_base_path }}/access.log"
state: touch
mode: 0644
owner: "{{ matrix_user_username }}"
group: "{{ matrix_user_username }}"
when: matrix_nginx_access_log_to_file|bool

#
# Tasks related to getting rid of matrix-nginx-proxy (if it was previously enabled)
@@ -186,3 +194,9 @@
path: "{{ matrix_nginx_proxy_data_path }}/matrix-synapse-metrics-htpasswd"
state: absent
when: "not matrix_nginx_proxy_proxy_synapse_metrics_basic_auth_enabled|bool or not matrix_nginx_proxy_proxy_synapse_metrics|bool"

- name: Ensure Matrix nginx-proxy configuration for base domain deleted
file:
path: "{{ matrix_nginx_proxy_base_path }}/access.log"
state: absent
when: "not matrix_nginx_proxy_enabled|bool"

+ 4
- 0
roles/matrix-nginx-proxy/templates/nginx/nginx.conf.j2 查看文件

@@ -33,7 +33,11 @@ http {
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

{% if matrix_nginx_access_log_to_file %}
access_log /var/log/nginx/access_file.log main;
{% else %}
access_log /var/log/nginx/access.log main;
{% endif %}

sendfile on;
#tcp_nopush on;


+ 3
- 0
roles/matrix-nginx-proxy/templates/systemd/matrix-nginx-proxy.service.j2 查看文件

@@ -31,6 +31,9 @@ ExecStart=/usr/bin/docker run --rm --name matrix-nginx-proxy \
-v {{ matrix_nginx_proxy_confd_path }}:/etc/nginx/conf.d:ro \
-v {{ matrix_ssl_config_dir_path }}:{{ matrix_ssl_config_dir_path }}:ro \
-v {{ matrix_static_files_base_path }}:{{ matrix_static_files_base_path }}:ro \
{% if matrix_nginx_access_log_to_file %}
-v {{ matrix_nginx_proxy_base_path }}/access.log:/var/log/nginx/access_file.log:rw \
{% endif %}
{% for volume in matrix_nginx_proxy_container_additional_volumes %}
-v {{ volume.src }}:{{ volume.dst }}:{{ volume.options }} \
{% endfor %}


Loading…
取消
儲存