我收到此错误:
Restarting nginx: nginx: [emerg] duplicate "log_format" name "timed_combined" in /etc/nginx/sites-enabled/default:8
nginx: configuration file /etc/nginx/nginx.conf test failed
每当我开始或重新启动我的nginx服务器时。这不会发生在之前。这是我/etc/nginx/sites-enabled/default
# You may add here your
# server {
# ...
# }
# statements for each of your virtual hosts
log_format timed_combined '$remote_addr - $remote_user [$time_local] '
'"$request" $status $body_bytes_sent '
'"$http_referer" "$http_user_agent" $request_time';
答案 0 :(得分:1)
" timed_combined" log_format在源中预定义;你需要使用你的名字,比如:
log_format my_log '$remote_addr - $remote_user [$time_local] '
'"$request" $status $body_bytes_sent '
'"$http_referer" "$http_user_agent" $request_time';
之后你需要重新定义access_log:
access_log /path/to/access.log my_log