How to disable the Nginx access log.

This is a guide on how to disable the Nginx access log.

The access log contains helpful information about the HTTP requests that were received by your web server. However, this log can take up disk space and increase the number of disk writes that your server is performing.

As a result, you may decide that you want to disable it.

In your nginx.conf file, you will find a directive that resembles the following line.

access_log /var/log/nginx/access.log

In the case above, Nginx has been instructed to log all HTTP requests to an access log file at “/var/log/nginx/access.log”

To disable this, you can simply replace the file path with the “off” option like so.

access_log off;

Disable the access log for a specific server block or website.

You can also enable and disable the access log on a server / site-by-site basis.

server {
    listen       80;
    server_name  your-website.com
    access_log  off;

In the configuration above, we disabled the access_log for a specific server block in the sites-available directory.

NB: Remember to always test your Nginx configuration before reloading!