For testing purposes, I am using nginx to listen on multiple ports when I send distributed http requests. I can see the request be received by nginx - but I need to know which of its ports actually got it. I can't see any options in the logs to flag this.
I guess an ugly alternative is to install multiple instances so their logs are separated, but there must be a better way than this...?
Anything you can access as a variable in nginx config, you can log, including non-standard http headers, etc.
The var you want to add is $server_port
log_format mycustomformat '$host $remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" $server_port';
access_log /var/log/nginx/access.log mycustomformat;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With