Answer the question
In order to leave comments, you need to log in
NGINX: how to set log_not_found value via variable substitution?
I would like to disable `log_not_found` logging for some files. There is no problem if you specify
location = /apple-touch-icon(.*)$ { access_log off; log_not_found off;}
map $request_uri $log_not_found_off {
"/apple-touch-icon.png" "off";
"/apple-touch-icon-precomposed.png" "off";
"/favicon.ico" "off";
default "on";
}
location / {
log_not_found "$log_not_found_off";
try_files $uri $uri/ /index.php?$query_string;
}
[emerg] invalid value "$log_not_found_off" in "log_not_found" directive, it must be "on" or "off"
location / {
if ($log_not_found_off = "off") {
log_not_found "off";
}
try_files $uri $uri/ /index.php?$query_string;
}
[emerg] "log_not_found_off" directive is not allowed here
server {
listen 80;
server_name foobar.local;
access_log /var/log/nginx/main.access.log combined ;
error_log /var/log/nginx/main.error.log error ;
rewrite_log on;
log_not_found "$log_not_found_off";
# ИЛИ
if ($log_not_found_off = "off") {
log_not_found $log_not_found_off;
}
...
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question