Welcome to Centmin Mod Community
Become a Member

Nginx centminmod nginx logging settings

Discussion in 'Nginx, PHP-FPM & MariaDB MySQL' started by Zykov, May 28, 2014.

  1. Zykov

    Zykov Member

    31
    7
    8
    May 28, 2014
    Ratings:
    +7
    Local Time:
    3:05 PM
    Nginx 1.7.1
    MariaDB 10
    Being newbie in web-development I was really confused when I've don't seen any log entries while reloading demodomain.com page. But I figured out "buffer=32k" trait and "access_log off" directive for static files.

    And now I wonder: it is generally good or bad idea (for production site) - do not log static files requests?
    Can I meansure traffic for specified virtual host without it?
    Maybe it's more useful to process log files with awstats or similar tool? Awstats can aggregate summary old info in files like awstats052014.txt and then you can start new log for new day.

    Which approach do you guys use commonly?

     
    Last edited: May 28, 2014
  2. eva2000

    eva2000 Administrator Staff Member

    54,110
    12,179
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,739
    Local Time:
    4:05 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    Yes access log buffering delays writing immediately to the access log for better performance http://nginx.org/en/docs/http/ngx_http_log_module.html

    Yeah static file request logging is disabled by default in the default include file /usr/local/nginx/conf/staticfiles.conf which is added to each Nginx virtual host (can be directly accessed as per FAQ 16 at http://centminmod.com/faq.html via command shortcut = statfilesinc)

    contents of /usr/local/nginx/conf/staticfiles.conf
    Code:
        location ~* \.(3gp|gif|jpg|jpeg|png|ico|wmv|avi|asf|asx|mpg|mpeg|mp4|pls|mp3|mid|wav|swf|flv|exe|zip|tar|rar|gz|tgz|bz2|uha|7z|doc|docx|xls|xlsx|pdf|iso)$ {
            gzip_static off;
            #add_header Pragma public;
            add_header Cache-Control "public, must-revalidate, proxy-revalidate";
            access_log off;
            expires 30d;
            break;
            }
    
        location ~* \.(js)$ {
            #add_header Pragma public;
            add_header Cache-Control "public, must-revalidate, proxy-revalidate";
            access_log off;
            expires 30d;
            break;
            }
    
        location ~* \.(css)$ {
            #add_header Pragma public;
            add_header Cache-Control "public, must-revalidate, proxy-revalidate";
            access_log off;
            expires 30d;
            break;
            }
    
        location ~* \.(html|htm|txt)$ {
            #add_header Pragma public;
            add_header Cache-Control "public, must-revalidate, proxy-revalidate";
            access_log off;
            expires 1d;
            break;
            }
    
        location ~* \.(eot|svg|ttf|woff)$ {
            #add_header Pragma public;
            add_header Cache-Control "public, must-revalidate, proxy-revalidate";
            access_log off;
            expires 30d;
            break;
            }
    
    The reason this was done was Centmin Mod original features came from original Centmin script which was for low end memory based VPSes - 256-512MB types with low 5-20GB disk space allocations. So reducing memory and disk space usage is important by disabling static file logging :)

    If you have enough memory and disk space, then re-enabling logging by commenting out with a hash # in front of each access_log off; line and restarting Nginx, would be useful for stats logging software such as Awstats (yeah another reason why stats logging isn't installed by default = to save memory and disk resources). Easier to just use Google Analytics which is what I do as I have VPS with memory as low as 128MB using tweak outlined in Getting Started guide at http://centminmod.com/getstarted.html#lowmem :)
     
    Last edited: May 28, 2014
  3. Zykov

    Zykov Member

    31
    7
    8
    May 28, 2014
    Ratings:
    +7
    Local Time:
    3:05 PM
    Nginx 1.7.1
    MariaDB 10
    eva2000, thanks for your fast and comprehensive reply!
    The tip for Google Analytics is really nice.
    But maybe I can use some tool which is already in Centmin Mod to get the precise traffic counters per virtualhost and per system itself (without the overhead caused by nginx logging) ?
     
  4. eva2000

    eva2000 Administrator Staff Member

    54,110
    12,179
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,739
    Local Time:
    4:05 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    Yeah right now no such tool for per virtual host traffic stats. Maybe in the future :)
     
  5. Matt

    Matt Well-Known Member

    929
    415
    63
    May 25, 2014
    Rotherham, UK
    Ratings:
    +671
    Local Time:
    6:05 AM
    1.5.15
    MariaDB 10.2
    I created a new static file config file for one of my sites, just so I could enable image request logging, as I've got over 20GB of attachments, and was previously serving them via a CDN before moving to SPDY and HTTPS, so wanted to see what was being requested and from where