W
W
webviktor2020-03-14 13:34:37
Nginx
webviktor, 2020-03-14 13:34:37

How to make map work?

I'm trying to fix the config. Everything works until I add an exception of local ip from the log.
I add $log_ip to access.log and all map directives stop working.
Tell me please, where is the jamb?
nginx -t says everything is ok.

config

server {
listen 192.168.1.105:80;
server_name domain.com;
access_log /var/www/httpd-logs/domain.com_http.access.log;
location / {
return 301 https://$host$request_uri;
}
}

log_format compression '$remote_addr - $remote_user [$time_local] '
'"$request" $status $body_bytes_sent '
'"$http_referer" "$http_user_agent" "$gzip_ratio"';

map $request_uri $loggable {
default 1;
~*\.(ico|css|js|gif|jpg|jpeg|png|svg|woff|ttf|eot|bot|Bot)$ 0;
}
map $http_user_agent $exbot_com {
~Pingdom 0;
~Sogou 0;
~AhrefsBot 0;
default 1;
}
map $remote_addr $log_ip {
"192.168.0.0/16" 0;
default 1;
}
server {
listen 192.168.1.105:443 ssl http2;
server_name domain.com;

access_log /var/www/httpd-logs/domain.com.access.log compression if=$loggable if=$exbot_com if=$log_ip;

...... и т.д.
}

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question