nginx: [warn] the “log_format” directive may be used only on “http” level in

2017-12-23 21:32:40 15764

版本:nginx/1.6.2

报错:


nginx: [warn] the "log_format" directive may be used only on "http" level in /usr/local/nginx/conf/extra/www.landui.com:9
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful


解决方法:日志配置信息写在server前面即可。


    log_format main '$remote_addr - $remote_user [$time_local] '
                    '"$request" $status $body_bytes_sent "$http_referer" '
                    '"$http_user_agent" "$http_x_forwarded_for"' ;
    access_log /usr/local/nginx/logs/access.log  main;


提交成功!非常感谢您的反馈,我们会继续努力做到更好!

这条文档是否有帮助解决问题?

非常抱歉未能帮助到您。为了给您提供更好的服务,我们很需要您进一步的反馈信息:

在文档使用中是否遇到以下问题: