diff --git a/config/config.sample.php b/config/config.sample.php
index 1560fe8ac39e6027f551375406ed81ba6c36fc77..216a32c8ebd4ccab2e5ae2869e3b813632332fe7 100644
--- a/config/config.sample.php
+++ b/config/config.sample.php
@@ -1619,6 +1619,15 @@ $CONFIG = [
  */
 'minimum.supported.desktop.version' => '2.0.0',
 
+/**
+ * Option to allow local storage to contain symlinks.
+ * WARNING: Not recommended. This would make it possible for Nextcloud to access
+ * files outside the data directory and could be considered a security risk.
+ *
+ * Defaults to ``false``
+ */
+'localstorage.allowsymlinks' => false,
+
 /**
  * EXPERIMENTAL: option whether to include external storage in quota
  * calculation, defaults to false.
diff --git a/lib/private/Files/Storage/Local.php b/lib/private/Files/Storage/Local.php
index 5d0ce596b11f7832b27f9ec5f391d2d193eadbb0..81d1d083eb8922bfc756e01a20e68125d30da220 100644
--- a/lib/private/Files/Storage/Local.php
+++ b/lib/private/Files/Storage/Local.php
@@ -58,8 +58,6 @@ class Local extends \OC\Files\Storage\Common {
 
 	protected $dataDirLength;
 
-	protected $allowSymlinks = false;
-
 	protected $realDataDir;
 
 	public function __construct($arguments) {
@@ -441,7 +439,8 @@ class Local extends \OC\Files\Storage\Common {
 
 		$fullPath = $this->datadir . $path;
 		$currentPath = $path;
-		if ($this->allowSymlinks || $currentPath === '') {
+		$allowSymlinks = \OC::$server->getConfig()->getSystemValue('localstorage.allowsymlinks', false);
+		if ($allowSymlinks || $currentPath === '') {
 			return $fullPath;
 		}
 		$pathToResolve = $fullPath;