.htaccess 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <IfModule mod_headers.c>
  2. <IfModule mod_setenvif.c>
  3. <IfModule mod_fcgid.c>
  4. SetEnvIfNoCase ^Authorization$ "(.+)" XAUTHORIZATION=$1
  5. RequestHeader set XAuthorization %{XAUTHORIZATION}e env=XAUTHORIZATION
  6. </IfModule>
  7. <IfModule mod_proxy_fcgi.c>
  8. SetEnvIfNoCase Authorization "(.+)" HTTP_AUTHORIZATION=$1
  9. </IfModule>
  10. <IfModule mod_lsapi.c>
  11. SetEnvIfNoCase ^Authorization$ "(.+)" XAUTHORIZATION=$1
  12. RequestHeader set XAuthorization %{XAUTHORIZATION}e env=XAUTHORIZATION
  13. </IfModule>
  14. </IfModule>
  15. <IfModule mod_env.c>
  16. # Add security and privacy related headers
  17. # Avoid doubled headers by unsetting headers in "onsuccess" table,
  18. # then add headers to "always" table: https://github.com/nextcloud/server/pull/19002
  19. <If "%{REQUEST_URI} =~ m#/login$#">
  20. # Only on the login page we need any Origin or Referer header set.
  21. Header onsuccess unset Referrer-Policy
  22. Header always set Referrer-Policy "same-origin"
  23. </If>
  24. <Else>
  25. Header onsuccess unset Referrer-Policy
  26. Header always set Referrer-Policy "no-referrer"
  27. </Else>
  28. Header onsuccess unset X-Content-Type-Options
  29. Header always set X-Content-Type-Options "nosniff"
  30. Header onsuccess unset X-Frame-Options
  31. Header always set X-Frame-Options "SAMEORIGIN"
  32. Header onsuccess unset X-Permitted-Cross-Domain-Policies
  33. Header always set X-Permitted-Cross-Domain-Policies "none"
  34. Header onsuccess unset X-Robots-Tag
  35. Header always set X-Robots-Tag "noindex, nofollow"
  36. Header onsuccess unset X-XSS-Protection
  37. Header always set X-XSS-Protection "1; mode=block"
  38. SetEnv modHeadersAvailable true
  39. </IfModule>
  40. # Add cache control for static resources
  41. <FilesMatch "\.(css|js|mjs|svg|gif|png|jpg|webp|ico|wasm|tflite)$">
  42. <If "%{QUERY_STRING} =~ /(^|&)v=/">
  43. Header set Cache-Control "max-age=15778463, immutable"
  44. </If>
  45. <Else>
  46. Header set Cache-Control "max-age=15778463"
  47. </Else>
  48. </FilesMatch>
  49. # Let browsers cache OTF and WOFF files for a week
  50. <FilesMatch "\.(otf|woff2?)$">
  51. Header set Cache-Control "max-age=604800"
  52. </FilesMatch>
  53. </IfModule>
  54. <IfModule mod_php.c>
  55. php_value mbstring.func_overload 0
  56. php_value default_charset 'UTF-8'
  57. php_value output_buffering 0
  58. <IfModule mod_env.c>
  59. SetEnv htaccessWorking true
  60. </IfModule>
  61. </IfModule>
  62. <IfModule mod_mime.c>
  63. AddType image/svg+xml svg svgz
  64. AddType application/wasm wasm
  65. AddEncoding gzip svgz
  66. # Serve ESM javascript files (.mjs) with correct mime type
  67. AddType text/javascript js mjs
  68. </IfModule>
  69. <IfModule mod_dir.c>
  70. DirectoryIndex index.php index.html
  71. </IfModule>
  72. <IfModule pagespeed_module>
  73. ModPagespeed Off
  74. </IfModule>
  75. <IfModule mod_rewrite.c>
  76. RewriteEngine on
  77. RewriteCond %{HTTP_USER_AGENT} DavClnt
  78. RewriteRule ^$ /remote.php/webdav/ [L,R=302]
  79. RewriteRule .* - [env=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
  80. RewriteRule ^\.well-known/carddav /remote.php/dav/ [R=301,L]
  81. RewriteRule ^\.well-known/caldav /remote.php/dav/ [R=301,L]
  82. RewriteRule ^remote/(.*) remote.php [QSA,L]
  83. RewriteRule ^(?:build|tests|config|lib|3rdparty|templates)/.* - [R=404,L]
  84. RewriteRule ^\.well-known/(?!acme-challenge|pki-validation) /index.php [QSA,L]
  85. RewriteRule ^ocm-provider/?$ index.php [QSA,L]
  86. RewriteRule ^(?:\.(?!well-known)|autotest|occ|issue|indie|db_|console).* - [R=404,L]
  87. </IfModule>
  88. # Clients like xDavv5 on Android, or Cyberduck, use chunked requests.
  89. # When FastCGI or FPM is used with apache, requests arrive to Nextcloud without any content.
  90. # This leads to the creation of empty files.
  91. # The following directive will force the problematic requests to be buffered before being forwarded to Nextcloud.
  92. # This way, the "Transfer-Encoding" header is removed, the "Content-Length" header is set, and the request content is proxied to Nextcloud.
  93. # Here are more information about the issue:
  94. # - https://docs.cyberduck.io/mountainduck/issues/fastcgi/
  95. # - https://docs.nextcloud.com/server/latest/admin_manual/issues/general_troubleshooting.html#troubleshooting-webdav
  96. <IfModule mod_setenvif.c>
  97. SetEnvIfNoCase Transfer-Encoding "chunked" proxy-sendcl=1
  98. </IfModule>
  99. # Apache disabled the sending of the server-side content-length header
  100. # in their 2.4.59 patch updated which breaks some use-cases in Nextcloud.
  101. # Setting ap_trust_cgilike_cl allows to bring back the usual behaviour.
  102. # See https://bz.apache.org/bugzilla/show_bug.cgi?id=68973
  103. <IfModule mod_env.c>
  104. SetEnv ap_trust_cgilike_cl
  105. </IfModule>
  106. AddDefaultCharset utf-8
  107. Options -Indexes