[Ansible] add upstreaminfo log format to nginx configuration #104349

Merged
Oleg-Komarov merged 1 commits from add-upstreaminfo-format into main 2023-10-05 16:52:30 +02:00
4 changed files with 22 additions and 1 deletions
Showing only changes of commit b9ac9fb18c - Show all commits

View File

@ -0,0 +1,14 @@
---
- name: "Writing {{ conf_d }}{{ conf_f }}"
vars:
conf_d: /etc/nginx/conf.d/
conf_f: log-format-upstreaminfo.conf
ansible.builtin.template:
src: "templates/nginx/conf.d/{{ conf_f }}"
dest: "{{ conf_d }}{{ conf_f }}"
backup: true
mode: 0664
tags:
- nginx
- config
- log_format

View File

@ -25,6 +25,8 @@
- import_tasks: tasks/copy_error_pages.yaml
- import_tasks: common/tasks/nginx/add_upstreaminfo_log_format.yaml
- name: Copying nginx config
ansible.builtin.template:
src: templates/nginx/https.conf

View File

@ -0,0 +1,5 @@
log_format upstreaminfo
'$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" "$http_user_agent" '
'$request_length $request_time [upstream-{{ env }}-service-1234] [upstream-{{ env }}-service-1234] $upstream_addr '
'$upstream_response_length $upstream_response_time $upstream_status $request_id';

View File

@ -21,7 +21,7 @@ server {
{% endfor %}
deny all;
{% endif %}
access_log /var/log/nginx/{{ domain }}-access.log;
access_log /var/log/nginx/{{ domain }}-access.log upstreaminfo;
error_log /var/log/nginx/{{ domain }}-error.log;
#location /robots.txt {