Nginx, piwik and old apps

help deal with the problem. My web server nginx serves multiple applications that are written in different languages and are running different servers - ASP, ruby, php. Web server acts as a reverse proxy by sending requests to the external customer applications.

Quite a long time pivik apply for statistics and just want to use it for these applications. But there’s a problem: install trakking code within the application is not technically feasible. Is it possible to set piwik tracking code inside the code of nginx vhost to track visitors? Nginx have sub_filter module that allows you to install javascript code inside each request, thereby transparently sending user’s browser to js-script piwik site. Anyone can help set up or show example configuration of that case ? All examples sort off

location / {
sub_filter_once on;
proxy_pass http://ruby-app;


was checked but client browser doesn’t look to my piwik site

thanks for reply