Why Nginx creates a file named "off"?
If you’ve ever found an unexpected file named off under /etc/nginx/, here’s the reason why.
When configuring Nginx, it’s possible to disable error logging. However, the directive must be used correctly:
error_log /dev/null;
If you mistakenly write:
error_log off;
Nginx will interpret off as a file path, not as a keyword, and will try to create (or write to) /etc/nginx/off.
That’s why you’ll find an empty file named off in your configuration directory.
This behavior happens because Nginx’s configuration parser does not treat off as a special keyword for the error_log directive.
Instead, it expects a file path as the first argument, followed optionally by a log level (like warn, error, or debug).
To disable logging properly, just redirect it to /dev/null, which effectively discards all log output:
error_log /dev/null;
This simple change prevents Nginx from creating the mysterious off file.
Have you ever had this problem? I have 😁 That’s why I decided to write a short post about it.