Change log format to VCOMBINED for access logs and debug for error logs
This commit is contained in:
@@ -10,7 +10,7 @@ events {
|
||||
}
|
||||
|
||||
http {
|
||||
include mime.types;
|
||||
include /etc/nginx/mime.types;
|
||||
default_type application/octet-stream;
|
||||
|
||||
keepalive_timeout 65;
|
||||
@@ -23,30 +23,31 @@ http {
|
||||
resolver 8.8.8.8 valid=30s ipv6=off;
|
||||
resolver_timeout 11s;
|
||||
|
||||
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
|
||||
'$status $body_bytes_sent "$http_referer" '
|
||||
'"$http_user_agent" "$http_x_forwarded_for"';
|
||||
|
||||
# JSON format — preferred for log aggregators (ELK, Loki, Datadog, etc.)
|
||||
log_format json_log escape=json
|
||||
'{'
|
||||
'"time":"$time_iso8601",'
|
||||
'"remote_addr":"$remote_addr",'
|
||||
'"method":"$request_method",'
|
||||
'"uri":"$request_uri",'
|
||||
'"status":$status,'
|
||||
'"bytes_sent":$body_bytes_sent,'
|
||||
'"request_time":$request_time,'
|
||||
'"upstream_response_time":"$upstream_response_time",'
|
||||
'"referer":"$http_referer",'
|
||||
'"user_agent":"$http_user_agent",'
|
||||
'"x_forwarded_for":"$http_x_forwarded_for",'
|
||||
'"host":"$host"'
|
||||
'}';
|
||||
# log_format json_combined escape=json '{'
|
||||
# '"method":"$request_method",'
|
||||
# '"scheme":"$scheme",'
|
||||
# '"domain":"$host",'
|
||||
# '"uri":"$request_uri",'
|
||||
# '"query_string":"$query_string",'
|
||||
# '"referer":"$http_referer",'
|
||||
# '"content_type":"$sent_http_content_type",'
|
||||
# '"status": $status,'
|
||||
# '"bytes_sent":$body_bytes_sent,'
|
||||
# '"request_time":$request_time,'
|
||||
# '"user_agent":"$http_user_agent",'
|
||||
# '"cache":"$upstream_cache_status",'
|
||||
# '"upstream_time": "$upstream_response_time",'
|
||||
# '"timestamp":"$time_iso8601",'
|
||||
# '"ip":"$http_x_forwarded_for"'
|
||||
# '}';
|
||||
log_format VCOMBINED '$host:$server_port '
|
||||
'$remote_addr $remote_user [$time_local] '
|
||||
'"$request" $status $body_bytes_sent '
|
||||
'"$http_referer" "$http_user_agent"';
|
||||
|
||||
|
||||
access_log /var/log/nginx/access.log json_log;
|
||||
error_log /var/log/nginx/error.log;
|
||||
access_log /var/log/nginx/access.log VCOMBINED;
|
||||
error_log /var/log/nginx/error.log debug;
|
||||
|
||||
sendfile on;
|
||||
tcp_nopush on;
|
||||
@@ -94,33 +95,3 @@ http {
|
||||
# Include all server configurations
|
||||
include /etc/nginx/conf.d/*.conf;
|
||||
}
|
||||
|
||||
# Existing http {} block stays as-is...
|
||||
|
||||
# TCP stream proxy for SMTP ports
|
||||
# stream {
|
||||
|
||||
# upstream mailserver_smtp {
|
||||
# server mailserver:25; # docker-mailserver container name
|
||||
# }
|
||||
|
||||
# upstream mailserver_submission {
|
||||
# server mailserver:587;
|
||||
# }
|
||||
|
||||
# # Port 25 — inbound MTA-to-MTA (if you ever receive external mail)
|
||||
# server {
|
||||
# listen 25;
|
||||
# proxy_pass mailserver_smtp;
|
||||
# proxy_timeout 1m;
|
||||
# proxy_connect_timeout 10s;
|
||||
# }
|
||||
|
||||
# # Port 587 — STARTTLS submission (for mail clients or apps)
|
||||
# server {
|
||||
# listen 587;
|
||||
# proxy_pass mailserver_submission;
|
||||
# proxy_timeout 1m;
|
||||
# proxy_connect_timeout 10s;
|
||||
# }
|
||||
# }
|
||||
Reference in New Issue
Block a user