Welcome to Centmin Mod Community
Become a Member

Piwik Analytics Centmin Mod Nginx Vhost Configuration

Discussion in 'Other Web Apps usage' started by eva2000, Sep 17, 2015.

  1. eva2000

    eva2000 Administrator Staff Member

    29,051
    6,592
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +9,788
    Local Time:
    11:22 AM
    Nginx 1.13.x
    MariaDB 5.5
    Been running Piwik Analytics dedicated Linode VPS server for a while now. So sharing my Centmin Mod Nginx vhost configuration with folks.

    Installation of Piwik and usage is left to end user as I am not providing any support for that so best to read documentation and FAQ and frequent their support forums

    Piwik Centmin Mod Nginx Vhost



    The piwik Nginx vhost - if you want to IP protect admin side of piwik uncomment #allow YOURIPADDRESS; and set your static IP address for your internet connection

    Code:
    location /piwik {
            allow      127.0.0.1;
            #allow      YOURIPADDRESS;
            deny       all;
            auth_basic "Restricted";
            auth_basic_user_file /usr/local/nginx/conf/piwik_htpasswd;
            try_files $uri $uri/ /piwik/index.php?$query_string;
    
            location = /piwik/piwik.js{
                    auth_basic off;
                    allow all;
            }
    
            location ~* ^/piwik(.+\.php)$ {
                    auth_basic off;
                    allow all;
                    include /usr/local/nginx/conf/php_piwik.conf;
            }
    }
    where auth_basic_user_file for HTTP password protection for piwik admin is created via below command in SSH. Be sure to change USERNAME and PASSWORD to your own username and password
    Code:
    /usr/local/nginx/conf/htpasswd.sh create /usr/local/nginx/conf/piwik_htpasswd USERNAME PASSWORD
    the configuration turns off HTTP password protection just for piwik.js and piwik.php files themselves

    The include file for piwik.php at /usr/local/nginx/conf/php_piwik.conf contents is just a modified version of /usr/local/nginx/conf/php.conf include with a different location match at top and HTTP password protection turned off

    Make a copy of /usr/local/nginx/conf/php.conf naming it /usr/local/nginx/conf/php_piwik.conf
    Code:
    cp -a /usr/local/nginx/conf/php.conf /usr/local/nginx/conf/php_piwik.conf
    edit /usr/local/nginx/conf/php_piwik.conf and replace top line

    from
    Code:
    location ~ \.php$ {
    to
    Code:
    location ~* ^/piwik/(.+\.php)$ {
    auth_basic off;
     
    Last edited: Sep 17, 2015
    • Informative Informative x 1
  2. Liam W

    Liam W Member

    57
    15
    8
    Jun 26, 2014
    Barrow-in-Furness, Cumbria, England
    Ratings:
    +19
    Local Time:
    2:22 AM
    nginx/1.9.11
    10.1.11
    I don't see the point in using basic auth for Piwik - it has decent auth systems built in...

    Liam
     
  3. eva2000

    eva2000 Administrator Staff Member

    29,051
    6,592
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +9,788
    Local Time:
    11:22 AM
    Nginx 1.13.x
    MariaDB 5.5
    Just an extra precaution - you can never be too sure in this day and age :D
     
  4. ModeltogTossen

    ModeltogTossen I wish I could??

    313
    97
    28
    Dec 20, 2015
    Denmark
    Ratings:
    +143
    Local Time:
    3:22 AM
    1.9.12
    10.0.23
    I would like to look into that instead of google analytics. Have one question.. Do you have piwik on the very same server, external (dedicated, vps) or are you guys using piwik cloud?

    If this is posted wrongly - please move it.
     
  5. eva2000

    eva2000 Administrator Staff Member

    29,051
    6,592
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +9,788
    Local Time:
    11:22 AM
    Nginx 1.13.x
    MariaDB 5.5
    I have dedicated Fremont, CA Linode 2GB VPS instance for Piwik server for my sites running Centmin Mod LEMP stack :)