nginx: [warn] the "log_format" directive may be used only on "http" level 解决方法

Nginx升级到 1.1.1*版本后,会出现警告:

nginx: [warn] the "log_format" directive may be used only on "http" level in /usr/local/nginx/conf/nginx.conf:84
将/usr/local/nginx/conf/nginx.conf 里server段里的下面代码移出放到该server段的前面即可。

log_format  access  '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" $http_x_forwarded_for';
如果有其的虚拟主机开启了日志,也按上面的要求移出server段放在server段的前面即可。

/usr/local/nginx/sbin/nginx -t
测试一下,没有warn警告信息了。

关键词: linux nginx