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"