moodle.tpl 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. server {
  2. listen %ip%:%web_port%;
  3. server_name %domain_idn% %alias_idn%;
  4. root %docroot%;
  5. index index.php index.html index.htm;
  6. access_log /var/log/nginx/domains/%domain%.log combined;
  7. access_log /var/log/nginx/domains/%domain%.bytes bytes;
  8. error_log /var/log/nginx/domains/%domain%.error.log error;
  9. rewrite ^/(.*\.php)(/)(.*)$ /$1?file=/$3 last;
  10. location = /favicon.ico {
  11. log_not_found off;
  12. access_log off;
  13. }
  14. location = /robots.txt {
  15. allow all;
  16. log_not_found off;
  17. access_log off;
  18. }
  19. # Very rarely should these ever be accessed outside of your lan
  20. location ~* \.(txt|log)$ {
  21. allow 192.168.0.0/16;
  22. deny all;
  23. }
  24. location ~ \..*/.*\.php$ {
  25. return 403;
  26. }
  27. # No no for private
  28. location ~ ^/sites/.*/private/ {
  29. return 403;
  30. }
  31. # Block access to "hidden" files and directories whose names begin with a
  32. # period. This includes directories used by version control systems such
  33. # as Subversion or Git to store control files.
  34. location ~ (^|/)\. {
  35. return 403;
  36. }
  37. location / {
  38. location ~* ^.+\.(jpeg|jpg|png|gif|bmp|ico|svg|css|js)$ {
  39. expires max;
  40. }
  41. location ~ [^/]\.php(/|$) {
  42. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  43. if (!-f $document_root$fastcgi_script_name) {
  44. return 404;
  45. }
  46. fastcgi_pass %backend_lsnr%;
  47. fastcgi_index index.php;
  48. fastcgi_param SCRIPT_FILENAME $request_filename;
  49. fastcgi_intercept_errors on;
  50. include /etc/nginx/fastcgi_params;
  51. }
  52. }
  53. error_page 403 /error/404.html;
  54. error_page 404 /error/404.html;
  55. error_page 500 502 503 504 /error/50x.html;
  56. location /error/ {
  57. alias %home%/%user%/web/%domain%/document_errors/;
  58. }
  59. location ~* "/\.(htaccess|htpasswd)$" {
  60. deny all;
  61. return 404;
  62. }
  63. location /vstats/ {
  64. alias %home%/%user%/web/%domain%/stats/;
  65. include %home%/%user%/conf/web/%domain%.auth*;
  66. }
  67. include /etc/nginx/conf.d/phpmyadmin.inc*;
  68. include /etc/nginx/conf.d/phppgadmin.inc*;
  69. include /etc/nginx/conf.d/webmail.inc*;
  70. include %home%/%user%/conf/web/nginx.%domain%.conf*;
  71. }