Advertisement
Guest User

simple php + web server config for NixOS, from piwik module

a guest
Aug 30th, 2017
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 KB | None | 0 0
  1. services.phpfpm.poolConfigs."piwik" = ''
  2. listen = "/run/phpfpm-piwik.sock"
  3. listen.owner = nginx
  4. listen.group = root
  5. listen.mode = 0600
  6. user = piwik
  7. ; default phpfpm process manager settings
  8. pm = dynamic
  9. pm.max_children = 75
  10. pm.start_servers = 10
  11. pm.min_spare_servers = 5
  12. pm.max_spare_servers = 20
  13. pm.max_requests = 500
  14. ; log worker's stdout, but this has a performance hit
  15. catch_workers_output = yes
  16. '';
  17. };
  18.  
  19.  
  20. services.nginx.virtualHosts."piwik.${config.networking.hostName}" = {
  21. root = "/srv/www/piwik";
  22.  
  23. forceSSL = true;
  24. enableACME = true;
  25.  
  26. locations."/" = {
  27. index = "index.php";
  28. };
  29. # allow index.php for webinterface
  30. locations."= /index.php".extraConfig = ''
  31. fastcgi_pass unix:/run/phpfpm-piwik.sock;
  32. '';
  33. # allow piwik.php for tracking
  34. locations."= /piwik.php".extraConfig = ''
  35. fastcgi_pass unix:/run/phpfpm-piwik.sock;
  36. '';
  37. # Any other attempt to access any php files is forbidden
  38. locations."~* ^.+\.php$".extraConfig = ''
  39. return 403;
  40. '';
  41. # Disallow access to unneeded directories
  42. # config and tmp are already removed
  43. locations."~ ^/(?:core|lang|misc)/".extraConfig = ''
  44. return 403;
  45. '';
  46. # Disallow access to several helper files
  47. locations."~* \.(?:bat|git|ini|sh|txt|tpl|xml|md)$".extraConfig = ''
  48. return 403;
  49. '';
  50. # No crawling of this site for bots that obey robots.txt - no useful information here.
  51. locations."= /robots.txt".extraConfig = ''
  52. return 200 "User-agent: *\nDisallow: /\n";
  53. '';
  54. # let browsers cache piwik.js
  55. locations."= /piwik.js".extraConfig = ''
  56. expires 1M;
  57. '';
  58. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement