最佳答案
We use following nginx site configure file in our production env.
log_format main '$http_x_forwarded_for - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" $request_time';
server {
root /srv/www/web;
server_name *.test.com;
access_log /var/log/nginx/xxx.test.com.access.log main;
Both "http://a.test.com/ping" and "http://b.test.com/ping" http request will be record in file xxx.test.com.access.log.
But there is a problem, nginx don't store "domain name" in xxx.test.com.access.log.
"http://a.test.com/ping" and "http://b.test.com/ping" share the same request "Get /ping".
How can I record "a.test.com" or "b.test.com" in nginx log?