@@ -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
@@ -70,7 +86,7 @@ server {
7086 listen 443 ssl http2;
7187 {{ if .SSL_SERVER_NAME }}server_name {{ .SSL_SERVER_NAME }}; {{ end }}
7288
73- access_log /var/log/nginx/{{ .APP }}-access.log;
89+ access_log /var/log/nginx/{{ .APP }}-access.log json ;
7490 error_log /var/log/nginx/{{ .APP }}-error.log;
7591
7692 ssl_certificate {{ .APP_SSL_PATH }}/server.crt;
0 commit comments