According to a blog post I found, disabling Nginx access log can speed things up. Nginx have to write to this file every time some one access the site.

But, when setting up fail2ban, I realized that these programs use the access logs to secure the server. So my question is, should I disable the access logs or should I enable them and setup fail2ban?


You can use buffer directive:

access_log  /spool/logs/nginx-access.log  gzip  buffer=32k;

This will buffer the access log activity into memory and once the limit has been reached Nginx will then write the logs - this should save disk I/O.

  • It will also compress the log file?
    – THpubs
    Aug 25 '12 at 8:16
  • The logs should be compressed by logrotate by default
    – HTF
    Aug 25 '12 at 8:20
  • But, if its compressed, can fail2ban read them without any problems?
    – THpubs
    Aug 25 '12 at 8:21
  • You can skip the gzip part, I just copied the syntax from Nginx wiki page. By default the most recent log is not compressed.
    – HTF
    Aug 25 '12 at 8:25
  • After adding the above line, it says : nginx: [emerg] unknown log format "gzip" in /etc/nginx/nginx.conf:34
    – THpubs
    Aug 25 '12 at 9:08

The information contained in your logs can be quite valuable (as you've noticed with regard to fail2ban).

Writing to logs is usually buffered and quite efficient. If your server is so busy that writing to your access log is causing you problems then you really need to re-engineer your environment.

Keeping the logs seems like a good thing to me.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.