nginxのログにリクエストヘッダーを出す

投稿者: ytyng 3 年, 10 ヶ月 前

log_format.conf

log_format header
'[$time_local]\n'
'$request\n'
'request ------------\n'
'remote_addr: $remote_addr\n'
'remote_user: $remote_user\n'
'request_time: $request_time\n'
'host: $http_host\n'
'referer: $http_referer\n'
'accept_encoding: $http_accept_encoding\n'
'accept_language: $http_accept_language\n'
'user_agent: $http_user_agent\n'
'x_forwarded_proto: $http_x_forwarded_proto\n'
'x_forwarded_for: $http_x_forwarded_for\n'
'x_forwarded_host: $http_x_forwarded_host\n'
'x_real_ip: $http_x_real_ip\n'
'response ------------\n'
'status: $status\n'
'size: $body_bytes_sent\n'
'content_type: $sent_http_content_type\n';

ansible playbook yaml

- remote_user: ubuntu
hosts: servers
become: yes
tasks:

- copy:
src: log_format.conf
    dest: /etc/nginx/conf.d/log_format.conf
    owner: root
    group: root
    mode: 0644

- name: "nginx の再起動"
    service:
    name: nginx
    state: restarted

nginx のサーバ設定

server {
listen 80 default;
...
access_log /var/log/nginx/torico-id-header.log header;

現在未評価

コメント

アーカイブ

2024
2023
2022
2021
2020
2019
2018
2017
2016
2015
2014
2013
2012
2011