File tree Expand file tree Collapse file tree 2 files changed +36
-1
lines changed
Expand file tree Collapse file tree 2 files changed +36
-1
lines changed Original file line number Diff line number Diff line change @@ -33,10 +33,29 @@ map $uri $needs_conversion {
3333 default "no";
3434}
3535
36+ # Set up a JSON log format for better structured logging.
37+ log_format json escape=json
38+ '{'
39+ '"timestamp": "$time_iso8601",'
40+ '"client_ip": "$remote_addr",'
41+ '"request_id": "$request_id",'
42+ '"http_method": "$request_method",'
43+ '"http_path": "$uri",'
44+ '"protocol": "$server_protocol",'
45+ '"user_agent": "$http_user_agent",'
46+ '"referer": "$http_referer",'
47+ '"status_code": $status,'
48+ '"bytes_sent": $body_bytes_sent,'
49+ '"request_time_secs": $request_time'
50+ '}';
51+
3652server {
3753 listen 8069;
3854 server_name localhost;
3955
56+ access_log logs/access.log json;
57+ error_log logs/error.log;
58+
4059 client_max_body_size 100M;
4160
4261 # Remove the random ID that Medium appends to post URLs. This effectively does the same redirect recommended by Ghost here:
Original file line number Diff line number Diff line change @@ -38,12 +38,28 @@ map $uri $needs_conversion {
3838 default "no";
3939}
4040
41+ # Set up a JSON log format for better structured logging.
42+ log_format json escape=json
43+ '{'
44+ '"timestamp": "$time_iso8601",'
45+ '"client_ip": "$remote_addr",'
46+ '"request_id": "$request_id",'
47+ '"http_method": "$request_method",'
48+ '"http_path": "$uri",'
49+ '"protocol": "$server_protocol",'
50+ '"user_agent": "$http_user_agent",'
51+ '"referer": "$http_referer",'
52+ '"status_code": $status,'
53+ '"bytes_sent": $body_bytes_sent,'
54+ '"request_time_secs": $request_time'
55+ '}';
56+
4157server {
4258 listen [::]:80;
4359 listen 80;
4460 server_name {{ .NOSSL_SERVER_NAME }};
4561
46- access_log /var/log/nginx/{{ .APP }}-access.log;
62+ access_log /var/log/nginx/{{ .APP }}-access.log json ;
4763 error_log /var/log/nginx/{{ .APP }}-error.log;
4864 underscores_in_headers off;
4965
You can’t perform that action at this time.
0 commit comments