Search code examples
phpapachenginxmatomo

Running Piwik on Nginx which is a reverse proxy to Apache


In my current environment I have a web app running on Apache (no php is being used) with Nginx serving as a reverse proxy.

If I have Piwik installed on Nginx, where all php is being served by Ngnix, will Piwik still be able to track analytics correctly if I have the Piwik javascript blocks included in the code that is running on the Apache servers?


Solution

  • The answer is yes. In the nginx.conf file you need to add

    location /path_to_piwik_files/ {
        try_files $uri $uri/ @proxy;
    }
    
    location @proxy {
       proxy_pass   http:/website;
    }