Join the community today
Register Now

Is something like this possible?

Discussion in 'System Administration' started by Jon Snow, Aug 24, 2018.

  1. Jon Snow

    Jon Snow Active Member

    917
    188
    43
    Jun 30, 2017
    Ratings:
    +293
    Local Time:
    9:50 AM
    Nginx 1.13.9
    MariaDB 10.1.31
    With CMM, is something like filtering out the following from access/error logs possible?

    Filter if ?liveupdate exists (from actual logs recorded, not when entering commands to search) :
    Code:
    POST /forum/index.php?liveupdate HTTP/2.0
    To prevent flooding in the logs from an XF add-on.

     
  2. eva2000

    eva2000 Administrator Staff Member

    58,895
    12,490
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +19,122
    Local Time:
    10:50 PM
    Nginx 1.31.x
    MariaDB 10.x/11.4+/12.3+
    Centmin Mod is provided as is so such configuration is left to end users to figure out.

    You can possibly filter out by url using an nginx map to a variable and edit access_log to exclude that nginx map variable for logging. Similar to how i excluded certain user agent/bots from logging in custom SSL log outlined at SSL - HTTP/TLS Protocol and SSL Cipher Usage Statistics Logging
    So for your instance, as per Module ngx_http_log_module
    so something like if request matches https://yourdomain.com/forum/index.php?liveupdate assign $nolog_liveupdate variable a value of 0 otherwise all other requests assign value of 1 (default)

    The nginx map
    Code (Text):
    map $http_host$request_uri $nolog_liveupdate {
         default                                                1;
         "~https://yourdomain.com/forum/index.php?liveupdate"  0;
    }
    

    maps go in /usr/local/nginx/conf/nginx.conf within http{} context usually after hash bucket lines i.e.
    Code (Text):
    http {
     map_hash_bucket_size 128;
     map_hash_max_size 4096;
     server_names_hash_bucket_size 128;
     server_names_hash_max_size 2048;
     variables_hash_max_size 2048;
    
    map $http_host$request_uri $nolog_liveupdate {
         default                                                1;
         "~https://yourdomain.com/forum/index.php?liveupdate"  0;
    }
    

    then use if conditional logging in access_log directive for your nginx site vhost config file which says log only requests that have $nolog_liveupdate value of 1 (which is all other requests exclude the liveupdate one which has value of 0)

    so you change your nginx site vhost's access_log line from
    Code (Text):
    access_log /home/nginx/domains/yourdomain.com/log/access.log combined buffer=256k flush=5m;
    

    to
    Code (Text):
    access_log /home/nginx/domains/yourdomain.com/log/access.log combined buffer=256k flush=5m if=$nolog_liveupdate;
    

    Haven't tested it so you will have to test and re-config the mapping if not correct