Nginx error Nginx: [Emerg] Unknown log format "main"

Source: Internet
Author: User

Fault Description:

Reported error after adding Nginx sub-configuration file: [Emerg] Unknown log format "main"

Unable to reload, carefully review the configuration without syntax errors after debugging to find that the definition of Log_format is written to the bottom of the HTTP module, causing the child configuration file to be unrecognized.


The wrong wording

include/opt/app/nginx/conf/conf.d/*.conf; Log_format Main ' $remote _addr-$remote _user [$time _local] "$request" "$status $body _bytes_sent" $h  Ttp_referer "" "$http _user_agent" "$http _x_forwarded_for"; Access_log/opt/logs/nginx/access.log main;}

I introduced the child configuration file before I defined the log format, so the report is not recognized


Workaround:

Write Log_format to the beginning of HTTP

http{Log_format main ' $remote _addr-$remote _user [$time _local] "$request" ' $status $body _bytes_s  Ent "$http _referer" "$http _user_agent" "$http _x_forwarded_for"; Access_log/opt/logs/nginx/access.log main;







This article is from the Linux SA John blog, so be sure to keep this source http://john88wang.blog.51cto.com/2165294/1672876

Nginx error: [Emerg] Unknown log format "main"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.