Discover Centmin Mod today
Register Now

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

    54,873
    12,240
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,811
    Local Time:
    7:59 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    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
  2. Liam W

    Liam W Member

    62
    17
    8
    Jun 26, 2014
    United Kingdom
    Ratings:
    +22
    Local Time:
    9:59 PM
    nginx
    10.3.x
    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

    54,873
    12,240
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,811
    Local Time:
    7:59 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    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:
    10:59 PM
    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

    54,873
    12,240
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,811
    Local Time:
    7:59 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    I have dedicated Fremont, CA Linode 2GB VPS instance for Piwik server for my sites running Centmin Mod LEMP stack :)
     
  6. Jimmy

    Jimmy Well-Known Member

    1,788
    390
    83
    Oct 24, 2015
    East Coast USA
    Ratings:
    +990
    Local Time:
    5:59 PM
    I wonder if using Piwik would result in worse google search results. If Google integrates analytics into their data and sees sites which are getting a lot of traffic, I'd think that would affect the search rankings. I know it probably "shouldn't" but I wonder if it actually does.
     
  7. eva2000

    eva2000 Administrator Staff Member

    54,873
    12,240
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,811
    Local Time:
    7:59 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    ???? I don't follow ?
     
  8. Jimmy

    Jimmy Well-Known Member

    1,788
    390
    83
    Oct 24, 2015
    East Coast USA
    Ratings:
    +990
    Local Time:
    5:59 PM
    Meaning if you use Google Analytics and Google has the data you get better search ranking vs. using Piwik where the data is private.
     
  9. eva2000

    eva2000 Administrator Staff Member

    54,873
    12,240
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,811
    Local Time:
    7:59 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    Oh i see

    I just use both GA + piwik :D