I need to exclude from logging a specific URL.
I'm getting in my logs a lot of this:
2022-11-10T01:41:14.909240104Z XX.XX.XX.XX - - [10/Nov/2022:01:41:14 +0000] "GET /myapp/readiness HTTP/1.1" 200 4771 "-" "EF-xx-HealthCheck-Client/1.0" "XX.XX.XX.XX"
2022-11-10T01:41:17.002141788Z XX.XX.XX.XX - - [10/Nov/2022:01:41:17 +0000] "GET /myapp/readiness HTTP/1.1" 200 4771 "-" "EF-xx-HealthCheck-Client/1.0" "XX.XX.XX.XX"
I tried this at the end of many location
blocks:
location ~ ^/myapp/readiness {
access_log off;
log_not_found off;
}
This was taken from:
How to turn off access log for only a certain url in this nginx configuration?
But it doesn't work, that's why I ask again.
What else can I do?
Edit:
Full nginx.conf
server {
listen 8080;
server_name localhost;
root /usr/share/nginx/html;
index /myapp/index.html;
ssl_protocols TLSv1.2;
gzip on;
gzip_min_length 1000;
gzip_comp_level 9;
gzip_buffers 16 8k;
gzip_http_version 1.0;
gzip_proxied any;
gzip_types
text/css
text/plain
text/javascript
application/javascript
application/json
application/x-javascript
application/xml
application/xml+rss
application/xhtml+xml
application/x-font-ttf
application/x-font-opentype
application/vnd.ms-fontobject
image/svg+xml
image/x-icon
application/rss+xml
application/atom_xml;
gzip_vary on;
gunzip on;
location / {
return 301 myapp/;
}
location ~ ^/myapp/mio-bff {
rewrite ^/myapp/mio-bff(.*)$ $1 break;
proxy_pass http://mio-bff.cl-myapp:80;
proxy_redirect off;
}
location ~ ^/myapp/myapp-admin-web {
rewrite ^/myapp/myapp-admin-web(.*)$ $1/ break;
proxy_pass http://myapp-admin-web.cl-myapp:80;
proxy_redirect off;
}
location ~ ^/myapp/mio-reports-bff {
rewrite ^/myapp/mio-reports-bff(.*)$ $1/ break;
proxy_pass http://mio-reports.cl-myapp:80;
proxy_redirect off;
}
location ~ ^/myapp/notifications-bff {
rewrite ^/myapp/notifications-bff(.*)$ $1/ break;
proxy_pass http://notifications-bff.cl-myapp:80;
proxy_redirect off;
}
location ~ ^/myapp/compensacion-bff {
rewrite ^/myapp/compensacion-bff(.*)$ $1/ break;
proxy_pass http://compensacion-bff.cl-myapp:80;
proxy_redirect off;
}
location ~ ^/myapp/mievolucion-bff {
rewrite ^/myapp/mievolucion-bff(.*)$ $1/ break;
proxy_pass http://mievolucion-bff.cl-myapp:80;
proxy_redirect off;
}
location ~ ^/myapp/requests-bff {
rewrite ^/myapp/requests-bff(.*)$ $1/ break;
proxy_pass http://requests-bff.cl-myapp:80;
proxy_redirect off;
}
location ~ ^/myapp/credentials-bff {
rewrite ^/myapp/credentials-bff(.*?)/?$ $1/ break;
proxy_pass http://credentials-web-bff.cl-myapp:5000;
proxy_redirect off;
}
location ~ ^/myapp/containerstatics {
rewrite ^/myapp/containerstatics/(.*)$ /statics/$1 break;
proxy_pass https://XXX.blob.core.windows.net;
proxy_redirect off;
}
location ~ ^/myapp/containerdynamics {
rewrite ^/myapp/containerdynamics/(.*)$ /dynamics/$1 break;
proxy_pass https://XXX.blob.core.windows.net;
proxy_redirect off;
}
location ~ ^/myapp/containerdocuments {
rewrite ^/myapp/containerdocuments/(.*)$ /documents/$1 break;
proxy_pass https://XXX.blob.core.windows.net;
proxy_redirect off;
}
location ~ ^/myapp/containerdocsprod {
rewrite ^/myapp/containerdocsprod/(.*)$ /myappdocsprod/$1 break;
proxy_pass https://XXX.blob.core.windows.net;
proxy_redirect off;
}
location ~* \.(?:css|js)$ {
try_files $uri =404;
access_log off;
expires 30d;
add_header Cache-Control public;
tcp_nodelay off;
open_file_cache max=3000 inactive=120s;
open_file_cache_valid 45s;
open_file_cache_min_uses 2;
open_file_cache_errors off;
}
location ~* \.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc|woff)$ {
try_files $uri =404;
expires 365d;
access_log off;
add_header Vary Accept-Encoding;
}
location ~ ^/myapp {
try_files $uri /myapp/index.html;
}
# Turn off loggin on readiness health check
location /myapp/readiness {
access_log off;
log_not_found off;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# Include MIME Types
include /etc/nginx/mime.types;
# Do not verify client ssl
ssl_verify_client off;
}
EDIT 2:
I tried by changing:
location ~ ^/myapp {
# index index.html;
try_files $uri /myapp/index.html;
}
location = /myapp/readiness {
access_log off;
log_not_found off;
}
With:
location ^~ /myapp/readiness {
access_log off;
log_not_found_off;
try_files $uri /myapp/index.html;
}
But I'm getting this loop:
XX.XX.XX.XX - - [10/Nov/2022:19:54:34 +0000] "GET /myapp/readiness HTTP/1.1" 301 170 "-" "kube-probe/1.21" "-"
XX.XX.XX.XX - - [10/Nov/2022:19:54:34 +0000] "GET /myapp/readiness HTTP/1.1" 301 170 "-" "kube-probe/1.21" "-"
XX.XX.XX.XX - - [10/Nov/2022:19:54:34 +0000] "GET /myapp/myapp/ HTTP/1.1" 301 170 "http://NN.NN.NN.NN:8080/myapp/readiness" "kube-probe/1.21" "-"
XX.XX.XX.XX - - [10/Nov/2022:19:54:34 +0000] "GET /myapp/myapp/ HTTP/1.1" 301 170 "http://NN.NN.NN.NN:8080/myapp/readiness" "kube-probe/1.21" "-"
XX.XX.XX.XX - - [10/Nov/2022:19:54:34 +0000] "GET /myapp/myapp/myapp/ HTTP/1.1" 301 170 "http://NN.NN.NN.NN:8080/myapp/myapp/" "kube-probe/1.21" "-"
XX.XX.XX.XX - - [10/Nov/2022:19:54:34 +0000] "GET /myapp/myapp/myapp/ HTTP/1.1" 301 170 "http://NN.NN.NN.NN:8080/myapp/myapp/" "kube-probe/1.21" "-"
XX.XX.XX.XX - - [10/Nov/2022:19:54:34 +0000] "GET /myapp/myapp/myapp/myapp/ HTTP/1.1" 301 170 "http://NN.NN.NN.NN:8080/myapp/myapp/myapp/" "kube-probe/1.21" "-"
XX.XX.XX.XX - - [10/Nov/2022:19:54:34 +0000] "GET /myapp/myapp/myapp/myapp/ HTTP/1.1" 301 170 "http://NN.NN.NN.NN:8080/myapp/myapp/myapp/" "kube-probe/1.21" "-"
XX.XX.XX.XX - - [10/Nov/2022:19:54:34 +0000] "GET /myapp/myapp/myapp/myapp/myapp/ HTTP/1.1" 301 170 "http://NN.NN.NN.NN:8080/myapp/myapp/myapp/myapp/" "kube-probe/1.21" "-"
XX.XX.XX.XX - - [10/Nov/2022:19:54:34 +0000] "GET /myapp/myapp/myapp/myapp/myapp/ HTTP/1.1" 301 170 "http://NN.NN.NN.NN:8080/myapp/myapp/myapp/myapp/" "kube-probe/1.21" "-"
XX.XX.XX.XX - - [10/Nov/2022:19:54:34 +0000] "GET /myapp/myapp/myapp/myapp/myapp/myapp/ HTTP/1.1" 301 170 "http://NN.NN.NN.NN:8080/myapp/myapp/myapp/myapp/myapp/" "kube-probe/1.21" "-"
XX.XX.XX.XX - - [10/Nov/2022:19:54:34 +0000] "GET /myapp/myapp/myapp/myapp/myapp/myapp/ HTTP/1.1" 301 170 "http://NN.NN.NN.NN:8080/myapp/myapp/myapp/myapp/myapp/" "kube-probe/1.21" "-"
XX.XX.XX.XX - - [10/Nov/2022:19:54:34 +0000] "GET /myapp/myapp/myapp/myapp/myapp/myapp/myapp/ HTTP/1.1" 301 170 "http://NN.NN.NN.NN:8080/myapp/myapp/myapp/myapp/myapp/myapp/" "kube-probe/1.21" "-"
XX.XX.XX.XX - - [10/Nov/2022:19:54:34 +0000] "GET /myapp/myapp/myapp/myapp/myapp/myapp/myapp/ HTTP/1.1" 301 170 "http://NN.NN.NN.NN:8080/myapp/myapp/myapp/myapp/myapp/myapp/" "kube-probe/1.21" "-"
XX.XX.XX.XX - - [10/Nov/2022:19:54:34 +0000] "GET /myapp/myapp/myapp/myapp/myapp/myapp/myapp/myapp/ HTTP/1.1" 301 170 "http://NN.NN.NN.NN:8080/myapp/myapp/myapp/myapp/myapp/myapp/myapp/" "kube-probe/1.21" "-"
XX.XX.XX.XX - - [10/Nov/2022:19:54:34 +0000] "GET /myapp/myapp/myapp/myapp/myapp/myapp/myapp/myapp/ HTTP/1.1" 301 170 "http://NN.NN.NN.NN:8080/myapp/myapp/myapp/myapp/myapp/myapp/myapp/" "kube-probe/1.21" "-"
XX.XX.XX.XX - - [10/Nov/2022:19:54:34 +0000] "GET /myapp/myapp/myapp/myapp/myapp/myapp/myapp/myapp/myapp/ HTTP/1.1" 301 170 "http://NN.NN.NN.NN:8080/myapp/myapp/myapp/myapp/myapp/myapp/myapp/myapp/" "kube-probe/1.21" "-"
XX.XX.XX.XX - - [10/Nov/2022:19:54:34 +0000] "GET /myapp/myapp/myapp/myapp/myapp/myapp/myapp/myapp/myapp/ HTTP/1.1" 301 170 "http://NN.NN.NN.NN:8080/myapp/myapp/myapp/myapp/myapp/myapp/myapp/myapp/" "kube-probe/1.21" "-"