1. server {
  2. listen 8001;
  3. server_name localhost;
  4. access_log /var/log/nginx/piwik.access.log;
  5. error_log /var/log/nginx/piwik.error.log;
  6. # Disable all methods besides HEAD, GET and POST.
  7. if ($request_method !~ ^(GET|HEAD|POST)$ ) {return 444;}
  8. root /home/tohuw/piwik/;
  9. include global/indexes.conf;
  10. # Disallow any usage of piwik assets if referer is non valid.
  11. location ~* ^.+\.(?:jpg|png|css|gif|jpeg|js|swf)$ {
  12. # Defining the valid referers.
  13. valid_referers none blocked *.mysite.com othersite.com;
  14. if ($invalid_referer) {return 444;}
  15. expires max;
  16. break;
  17. }
  18. # Support for favicon. Return a 204 (No Content) if the favicon
  19. # doesn't exist.
  20. location = /favicon.ico {try_files /favicon.ico =204;}
  21. # Try all locations and relay to index.php as a fallback.
  22. location / {try_files $uri /index.php;}
  23. # Relay all index.php requests to fastcgi.
  24. location ~* ^/(?:index|piwik)\.php$ {fastcgi_pass unix:/tmp/php-cgi/php-cgi.socket;}
  25. # Any other attempt to access PHP files returns a 404.
  26. location ~* ^.+\.php$ {return 404;}
  27. # Return a 404 for all text files.
  28. location ~* ^/(?:README|LICENSE[^.]*|LEGALNOTICE)(?:\.txt)*$ {return 404;}
  29. # # The 404 is signaled through a static page.
  30. # error_page 404 /404.html;
  31. # ## All server error pages go to 50x.html at the document root.
  32. # error_page 500 502 503 504 /50x.html;
  33. # location = /50x.html {
  34. # root /var/www/nginx-default;
  35. # }
  36. }