access logs log_format to json (#44)

access logs log_format to json
pull/56/head
naftulee 2020-10-08 17:35:25 +03:00 committed by GitHub
parent 0419eb4db7
commit 16c3e250b7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 54 additions and 23 deletions

View File

@ -16,28 +16,59 @@ http {
default_type application/octet-stream; default_type application/octet-stream;
# Use a debug-oriented logging format. # Use a debug-oriented logging format.
log_format debugging '$remote_addr - $remote_user [$time_local] "$request" ' log_format debugging escape=json
'$status $body_bytes_sent ' '{'
'"HOST: $host" "UPSTREAM: $upstream_addr" ' '"access_time":"$time_local",'
'"UPSTREAM-STATUS: $upstream_status" ' '"remote_addr":"$remote_addr",'
'"SSL-PROTO: $ssl_protocol" ' '"remote_user":"$remote_user",'
'"CONNECT-HOST: $connect_host" "CONNECT-PORT: $connect_port" "CONNECT-ADDR: $connect_addr" ' '"request":"$request",'
'"PROXY-HOST: $proxy_host" "UPSTREAM-REDIRECT: $upstream_http_location" "CACHE-STATUS: $upstream_cache_status" ' '"status":"$status",'
'"AUTH: $http_authorization" ' ; '"bytes_sent":"$body_bytes_sent",'
'"host":"$host",'
'"proxy_host":"$proxy_host",'
'"upstream":"$upstream_addr"'
'"upstream_status":"$upstream_status",'
'"ssl_protocol":"$ssl_protocol",'
'"connect_host":"$connect_host",'
'"connect_port":"$connect_port",'
'"connect_addr":"$connect_addr",'
'"upstream_http_location":"$upstream_http_location",'
'"upstream_cache_status":"$upstream_cache_status",'
'"http_authorization":"$http_authorization",'
'}';
log_format debug_proxy 'CONNECTPROXY: $remote_addr - $remote_user [$time_local] "$request" ' log_format debug_proxy escape=json
'$status $body_bytes_sent ' '{'
'"HOST: $host" "UPSTREAM: $upstream_addr" ' '"access_time":"$time_local",'
'"UPSTREAM-STATUS: $upstream_status" ' '"remote_addr":"$remote_addr",'
'"SSL-PROTO: $ssl_protocol" ' '"remote_user":"$remote_user",'
'"CONNECT-HOST: $connect_host" "CONNECT-PORT: $connect_port" "CONNECT-ADDR: $connect_addr" "INTERCEPTED: $interceptedHost" ' '"request":"$request",'
'"PROXY-HOST: $proxy_host" "UPSTREAM-REDIRECT: $upstream_http_location" "CACHE-STATUS: $upstream_cache_status" ' '"status":"$status",'
'"AUTH: $http_authorization" ' ; '"bytes_sent":"$body_bytes_sent",'
'"host":"$host",'
'"proxy_host":"$proxy_host",'
'"upstream":"$upstream_addr"'
'"upstream_status":"$upstream_status",'
'"ssl_protocol":"$ssl_protocol",'
'"connect_host":"$connect_host",'
'"connect_port":"$connect_port",'
'"connect_addr":"$connect_addr",'
'"upstream_http_location":"$upstream_http_location",'
'"upstream_cache_status":"$upstream_cache_status",'
'"http_authorization":"$http_authorization",'
'}';
log_format tweaked '$upstream_cache_status [$time_local] "$uri" ' log_format tweaked escape=json
'$status $body_bytes_sent ' '{'
'"HOST:$host" ' '"access_time":"$time_local",'
'"PROXY-HOST:$proxy_host" "UPSTREAM:$upstream_addr" '; '"upstream_cache_status":"$upstream_cache_status",'
'"uri":"$uri",'
'"status":"$status",'
'"bytes_sent":"$body_bytes_sent",'
'"host":"$host",'
'"proxy_host":"$proxy_host",'
'"upstream":"$upstream_addr"'
'}';
keepalive_timeout 300; keepalive_timeout 300;
gzip off; gzip off;