]> source.dussan.org Git - nextcloud-server.git/commitdiff
Extending the X-accel redirect functionality with a more scalable approach.
authordratini0 <dratini0@gmail.com>
Wed, 11 Feb 2015 21:10:06 +0000 (22:10 +0100)
committerdratini0 <dratini0@gmail.com>
Wed, 11 Feb 2015 21:19:22 +0000 (22:19 +0100)
lib/private/files.php

index 98f3c52d6c6227a0a38c98607137ac69fdf57d39..3a2e291630be90e8e5d45afc2676928128c3f0a7 100644 (file)
@@ -182,7 +182,16 @@ class OC_Files {
                }
 
                if (isset($_SERVER['MOD_X_ACCEL_REDIRECT_ENABLED'])) {
-                       $filename = \OC::$WEBROOT . '/data' . \OC\Files\Filesystem::getRoot() . $filename;
+                       if (isset($_SERVER['MOD_X_ACCEL_REDIRECT_PREFIX'])) {
+                               $prefix = $_SERVER['MOD_X_ACCEL_REDIRECT_PREFIX'];
+                               // nginx is picky about double slashes
+                               while($prefix[strlen($prefix) - 1] === '/'){
+                                       $prefix = substr($prefix, 0, -1);
+                               }
+                               $filename = $prefix . \OC\Files\Filesystem::getLocalFile($filename);
+                       } else {
+                               $filename = \OC::$WEBROOT . '/data' . \OC\Files\Filesystem::getRoot() . $filename;
+                       }
                        header("X-Accel-Redirect: " . $filename);
                }
        }