V
V
Vincent12020-12-29 19:02:13
Nginx
Vincent1, 2020-12-29 19:02:13

How to disable robots.txt logging in Nginx?

location = /robots.txt {
  allow all;
  log_not_found off;
  access_log off;
}


This option makes robots.txt unavailable - 404 error.
How to disable logging for robots.txt?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
Vincent1, 2021-01-07
@Vincent1

Thanks to Lynn "Coffeeman"

server {
    listen      172.67.196.42:443;
    server_name iherney.com www.iherney.com *.demo.iherney.com;
    ssl         on;
    ssl_certificate      /home/iherney/conf/web/ssl.iherney.com.pem;
    ssl_certificate_key  /home/iherney/conf/web/ssl.iherney.com.key;
    error_log  /var/log/apache2/domains/iherney.com.error.log error;
    root           /home/iherney/web/iherney.com/public_html;

    location / {
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

        proxy_pass      https://172.67.196.42:8443;
        location ~* ^.+\.(jpg|jpeg|gif|png|ico|svg|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|odt|ods|odp|odf|tar|wav|bmp|rtf|js|mp3|avi|mpeg|flv|html|htm)$ {
            root           /home/iherney/web/iherney.com/public_html;
            access_log     /var/log/apache2/domains/iherney.com.log combined;
            access_log     /var/log/apache2/domains/iherney.com.bytes bytes;
            expires        max;
            try_files      $uri @fallback;
        }
    }

    location = /robots.txt {
        allow all;
        log_not_found off;
        access_log off;
    }

    location /error/ {
        alias   /home/iherney/web/iherney.com/document_errors/;
    }

    location @fallback {
        proxy_pass      https://172.67.196.42:8443;
    }

    location ~ /\.ht    {return 404;}
    location ~ /\.svn/  {return 404;}
    location ~ /\.git/  {return 404;}
    location ~ /\.hg/   {return 404;}
    location ~ /\.bzr/  {return 404;}

    include /home/iherney/conf/web/snginx.iherney.com.conf*;
}

K
ky0, 2020-12-29
@ky0

Your variant does not work, because, apparently, no processing is provided outside this location. Either duplicate what happens on the rest of the site inside, or make this location nested in the main one.

V
Viktor Taran, 2020-12-30
@shambler81

OpenWRT Nginx - how to disable access.log if it doesn't understand "access_log" directive?
the option of logs in dev zero is also available

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question