Get the most out of your Centmin Mod LEMP stack
Become a Member

Beta Branch switch nginx access_log to custom main_ext format by default 123.09beta01

Discussion in 'Centmin Mod Github Commits' started by eva2000, Jul 5, 2016.

  1. eva2000

    eva2000 Administrator Staff Member

    30,613
    6,862
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,304
    Local Time:
    8:51 PM
    Nginx 1.13.x
    MariaDB 5.5
    switch nginx access_log to custom main_ext format by default 123.09beta01

    This allows out of the box native support for all Nginx Amplify metrics outlined at nginx-amplify-doc/amplify-guide.md at master · nginxinc/nginx-amplify-doc · GitHub to get the most out of custom Nginx Amplify dashboards Introducing Custom Dashboards in NGINX Amplify - NGINX.

    If main_ext format is not detected in /usr/local/nginx/conf/nginx.conf, it falls back to setting up access_log with nginx default combined format for best compatibility with older centmin mod installs which don't have the new main_ext format defined in /usr/local/nginx/conf/nginx.conf.

    If you want to manually add the new format in /usr/local/nginx/conf/nginx.conf, just add this log_format for main_ext within http {} context
    Code (Text):
    log_format  main_ext '$remote_addr - $remote_user [$time_local] "$request" '
                             '$status $body_bytes_sent "$http_referer" '
                             '"$http_user_agent" "$http_x_forwarded_for" '
                             'rt=$request_time ua="$upstream_addr" '
                             'us="$upstream_status" ut="$upstream_response_time" '
                             'ul="$upstream_response_length" '
                             'cs=$upstream_cache_status' ;
    

    then in each nginx vhost domain config i.e. domain.com.conf, change the access_log line

    from
    Code (Text):
    access_log /home/nginx/domains/domain.com/log/access.log combined buffer=256k flush=60m;
    

    to
    Code (Text):
    access_log /home/nginx/domains/domain.com/log/access.log main_ext buffer=256k flush=60m;
    


    You'd want to update the main hostname's nginx vhost at /usr/local/nginx/conf/conf.d/virtual.conf too.

    from
    Code (Text):
    access_log              /var/log/nginx/localhost.access.log     combined buffer=256k flush=5m;
    

    to
    Code (Text):
    access_log              /var/log/nginx/localhost.access.log     main_ext buffer=256k flush=5m;
    

    where domain.com is your domain name. Then restart nginx server

    Continue reading...

    123.09beta01 branch

     
    Last edited: Jul 5, 2016