Repository navigation
Replies: 1 comment 1 reply
|
@foofoodog Good point, thanks for spelling it out with code. |
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Problem
When self-hosting Layerling with PHP, project files are typically saved in a
store/folder located right next tostore.phpinside the public web document root (/var/www/html/store/).While
store.phpgenerates a.htaccessfile to block direct HTTP access, storing user files inside the document root presents a security risk if:AllowOverride(ignoring.htaccess).Currently,
store.phphardcodes the storage location to__DIR__ . DIRECTORY_SEPARATOR . STORE_DIRECTORY, preventing deployments from relocating the data directory outside the web root.Solution
Modify
store.phpto resolve its storage path from an optional environment variable (e.g.LAYERLING_STORE_PATH), falling back to the current default path for full backward compatibility.1. Change in
store.phpDefine a helper function to resolve the base directory:
Then in
store_root()andensure_store_guard(), replace:2. Change in
compose.ymlMount the storage directory outside
/var/www/html/(e.g., at/var/shared-projects) and set the environment variable:Why This Addresses the Problem
DocumentRootis/var/www/html. Because/var/shared-projectsis completely outside the web root and has no URL mapping, the web server cannot serve those files under any URL..htaccess: Security no longer depends on web server override rules or.htaccessparsing.store.phpreads and writes files via local filesystem calls, completely unaffected by web server routing.store/folder as before.All reactions