nginx using uninitialized "XXXX" variable while logging request

背景

最近在查看nginx的日志的时候,发现了有一条很奇怪的日志,就全力去排查。

错误日志:

nginx.conf配置:

触发条件:
访问:http://localhost:8907/logo之后,会在error日志中记录下using uninitialized "XXXX" variable while logging request的日志

原因

虽然set设置的变量是全局变量,但是每个location中对于set设置的全局变量如果没有赋值,也是未定义变量。如果使用了就会触发警告。

原文地址:https://www.cnblogs.com/MyUniverse/p/15505633.html