mediawiki.conf 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. server {
  2. listen 80;
  3. listen [::]:80;
  4. root /var/www/wiki;
  5. # Add index.php to the list if you are using PHP
  6. index index.php index.html index.htm;
  7. server_name localhost;
  8. access_log /var/log/nginx/wiki-access.log;
  9. error_log /var/log/nginx/wiki-error.log;
  10. # Allow favicon.ico, robots.txt, .well-known/
  11. # Deny *.txt, *.log, .*/*.php, .*, *.json, .lock, *.ht
  12. include snippets/allowed.conf;
  13. include snippets/denied.conf;
  14. location / {
  15. # First attempt to serve request as file, then
  16. # as directory, then fall back to displaying a 404.
  17. try_files $uri $uri/ =404;
  18. error_page 404 = @mediawiki;
  19. }
  20. # Rewrite for Short-URL
  21. location @mediawiki {
  22. rewrite ^/wiki([^?]*)(?:\?(.*))? /index.php?title=$1&$2 last;
  23. }
  24. # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
  25. #
  26. location ~ \.php$ {
  27. include snippets/fastcgi-php.conf;
  28. # # With php7.2-fpm:
  29. fastcgi_pass unix:/run/php/php7.2-fpm.sock;
  30. }
  31. # Disable php in /images/ (security)
  32. location ^~ /images/ {
  33. #Served like static files
  34. }
  35. # Deny access to deleted images folder
  36. location ^~ /images/deleted/ {
  37. deny all;
  38. }
  39. # Deny access to MediaWiki dirs
  40. location ^~ /cache/ { deny all; }
  41. location ^~ /languages/ { deny all; }
  42. location ^~ /maintenance/ { deny all; }
  43. location ^~ /serialized/ { deny all; }
  44. location ^~ /mw-config/ { deny all; }
  45. # Deny .svn and .git
  46. location ~ /.(svn|git)(/|$) { deny all; }
  47. }