ScaleScaleScaleScale

Tips / Nginx


How to configure Nginx debug

In this tutorial we will cover how to enable debuggin log in Nginx. Nginx by default doesn’t come with debuggin option activated, so, what we need to activate the debug function, is to enable debugging during the ./configure process.

For example:

./configure --with-debug ...

At this point, debug level has been activated to work with the error_log directive.
It should be used in this way:

error_log /path/to/log debug;

On the other side, Windows Nginx version has been always built with the debugging support activated, so there is no need to recompile.

You can have multiple error_log directives, one without debuggin and another one, for a specific location, with debugging activated:

server {
...
...
error_log /var/logs/nginx/error.log;

location /uploads/ {
error_log /var/logs/nginx/uploads-error.log debug;
}
...
...
}

And if you like, you can also limit the debuggin to certain hosts/ips:

error_log  /var/logs/nginx/home_connection-error.log debug;
events {
    debug_connection   10.0.0.1;
    debug_connection   10.0.1.0/24;
}

Popular search terms:

  • nginx debug log
  • how to debug nginx
  • nginx debug
  • nginx log level debug
profile

Esteban Borges

Linux Geek, Webperf Addict, Nginx Fan. CTO @Infranetworking