Keeping moodledata and vendor directories off the web

Private Moodle paths such as moodledata, vendor and node_modules must never be served over HTTP. This page covers how to place them, the 5.1 /public document root, and the security report checks that confirm it.

On this page

Why keeping moodledata and vendor directories off the web matters on Moodle

This page covers keeping the moodledata directory and vendor dependency trees off the public web on a self-hosted Moodle. If your Moodle is reachable from the internet, the web server document root is the boundary that decides what anyone can request. Anything stored beneath that root and not blocked by the web server can be fetched by a browser without signing in to Moodle. On a Moodle site, that means the file store for course uploads, user files and temporary data, and the backups and dependency trees that sit next to the application code. An exposed path can reveal user files, course material, configuration fragments or source files that show how the site is built, which makes it easier to target other weaknesses.

Teams should check this at three points: when the site is first installed, whenever the web server configuration changes (new virtual host, new reverse proxy, a move to a container image or a new TLS termination layer), and before or during any upgrade to Moodle 5.1 or later. Moodle 5.1 changed the layout so that the web server document root must point to the new /public directory rather than the main Moodle folder, and the release notes warn that a misconfigured root can show directory listings or errors. Confirm the exact document root and the path behavior for your Moodle version against the Moodle 5.1 release notes and your own test server, rather than relying on an older install guide.

DeployOpen configures the web server and Moodle paths together, sets dataroot outside the web root in the install, blocks direct access to vendor and node_modules paths where they exist, and then runs the Moodle security overview report and direct HTTP requests against the sensitive paths to confirm they return denial or not-found responses. Findings are documented with the exact server block or configuration key changed, so your team can reproduce the setting after the next upgrade. Ask any partner to show the requests they ran and the responses they expected and received.

Path placement options and when each fits

This table compares the three ways to keep private Moodle paths unreachable from the web: placing dataroot outside the web root, pointing the web server at the Moodle 5.1 /public directory, and blocking vendor and node_modules at the web server. Read each row as a separate control, because the options are often combined rather than chosen one at a time. The main takeaway is that the 5.1 /public layout depends on the document root setting, while the other two depend on server rules that your team must write and test.

OptionWhen it fitsWhat it depends onTrade-off
Dataroot outside the web rootAny Moodle install where the web server can be pointed at a folder that is not the dataroot, including older versionsDataroot location set at install and in config, with storage on a path the web server does not exposeNeeds correct file permissions for the web and cron users, and backup scripts must include the path
Moodle 5.1 /public document rootSites on Moodle 5.1 or later that can change the virtual host or server document rootDocument root set to the new /public directory, as the 5.1 release notes describe, instead of the main Moodle folderWithout the change, directory listings or errors can appear, so every new server or proxy must be checked
Blocking vendor and node_modules at the web serverSites where the code tree sits under the web root and the layout cannot be changed quicklyWeb server deny rules for vendor and node_modules paths, tested with direct requests after each deployRules are easy to miss in new virtual hosts, and they do not protect files if a future path is added without a rule
Combined approachPublic sites that need defence in depth and a planned upgrade path to 5.1 or laterDataroot outside web root, /public as document root, and deny rules kept as a second layerMore configuration to review after upgrades and plugin installs, so the security report checks should be re-run
Relying on Moodle aloneNot a placement choice, and it does not fit a public siteMoodle does not replace web server path controls for files it never servesSecurity report checks help verify exposure but do not block requests on their own

How to confirm private paths are not served

This sequence sets the install layout, points the web server at the correct public folder, keeps data and dependency directories out of reach, and confirms each result with direct requests and the security overview report. The output is a documented, repeatable check that private paths return no content.

  1. Decide the install layout first

    The platform team chooses where the code, moodledata and any dependency directories sit on disk before the web server is configured. Write the paths down in the build record, with the Moodle code folder, the data directory and the web server user, so every later check refers to the same locations. Confirm the layout against the install documentation for your Moodle version. Done means a single diagram or table exists that names every directory that must stay private.

  2. Confirm the Moodle version and document root

    The administrator checks the installed version under Site administration and matches it to the release notes. For Moodle 5.1 and later, the web server document root must point to the new /public directory rather than the main Moodle folder, because otherwise the site may show directory listings or errors. For earlier versions, confirm the document root is the folder the install guide specifies. Done means the version and the expected root are recorded together.

  3. Point the web server at the correct folder

    The web server engineer sets the document root directive in the virtual host or server block to the /public directory on 5.1 and later, and reloads the configuration. Only that folder should be exposed through the web server, so the Moodle code above it is never addressed by URL. Verify the configuration file parses without errors before reloading. Done means the configuration test passes and the live site loads from the public path.

  4. Keep moodledata and dependencies outside the root

    The engineer confirms that the data directory and any vendor or node_modules directories are located outside the web server document root, and that no alias or symbolic link maps them back into the served tree. Review the server configuration for aliases, and list the document root contents on disk. Done means the data directory and dependency folders are not reachable from any folder the web server serves.

  5. Request private paths directly

    From a machine outside the internal network, request the data directory path, a vendor directory path, a dependency path and a directory listing URL in a browser or with curl. Each request should return a denial, a not-found response or a redirect to the login page, never file contents or an index of files. Repeat the test after restarting the web server and PHP service. Record the status codes and responses in the build record. Done means every private path returns no content.

  6. Run the security overview report

    The administrator opens Site administration, then the security overview report, and reviews the checks that test web-accessible directories and the document root. Any finding about exposed data or code directories must be resolved before the site goes live, and the report result should be saved with the date and version. Confirm the report shows no failed item for those checks. Done means the report is saved and its findings are either cleared or documented with an owner.

  7. Re-run checks after every upgrade and plugin install

    After each Moodle upgrade, minor release or plugin installation, repeat the direct URL requests and the security overview report. Upgrades can change the document root expectations and new plugins can add folders that should not be served, so the checks must follow each change. Ask the vendor or your release owner to confirm any layout changes in the release notes for that version. Done means the post-change results are recorded alongside the change ticket.

Security risks when private paths leak

When a web server can reach directories that were meant to stay private, the exposure is usually quiet: a listing, a downloadable file or a readable version string. The risks below share one root cause, a web root that is wider than it should be, and they tend to return after upgrades, web server changes or new plugin installs unless someone checks them again.

Directory listings and error pages

If the web server document root points at the main Moodle folder instead of the public directory, requests for folders can return directory listings or raw error output. From Moodle 5.1, the document root must point to the new /public directory, so a site that was not repointed during an upgrade can expose its file tree. Check by requesting a few folder paths directly from outside your network and confirm that each returns a 403 or 404 page, not a listing.

Moodle 5.1 release notes

Uploaded files and backups in moodledata

The moodledata directory holds user uploads, course files, cache and backup archives. If it is reachable over HTTP, anyone who guesses or obtains a file path can download content that was meant only for enrolled users. Confirm that $CFG->dataroot sits outside the web root, that the web server has no alias to it, and that backup files cannot be fetched by URL. This check should be repeated after any change to storage or reverse proxy settings.

Exposed Composer and npm trees

The vendor and node_modules directories contain library code, lock files and package manifests. When they are served, an outsider can read exact library versions and look up known vulnerabilities for them, which makes targeted attacks easier. Moodle's public directory layout keeps these trees out of the served path, but a web server rule that serves the whole installation can still expose them. Request a known path such as a manifest file from outside the network and confirm it is refused.

Drift after upgrades and server changes

A path that was private at go-live can become public after a Moodle upgrade, a new web server virtual host, a CDN or load balancer change, or a plugin that adds its own directory. Each change can move the document root or add an alias without anyone noticing. Keep a written list of the paths that must return refusals, rerun the security overview report, and repeat the external request checks after every upgrade, plugin install and web server edit.

Checks by environment: Apache, Nginx and containers

On a traditional virtual machine, the web server's virtual host definition sets the document root. From Moodle 5.1, that document root should point to the public directory inside the Moodle code folder, not to the main Moodle folder. If the virtual host still points at the code root, Moodle's own files, including vendor and development directories, may be reachable as static files, and the site may show directory listings or errors. Confirm the exact directive names, module settings and any Directory or Files blocks with your platform team, because they depend on the Apache version and how your distribution packages the site.

  • Document root in the virtual host: Check that the DocumentRoot for the Moodle host resolves to the public directory on the 5.1 or later layout.
  • Directory listing: Request a directory such as /vendor/ or /moodledata/ and confirm the server returns a not-found or forbidden response, not a listing.
  • Override rules: Review any .htaccess files and AllowOverride settings, since rules copied from older guides can re-expose paths.
  • Dataroot location: Confirm $CFG->dataroot in config.php sits outside the web root, and that no alias maps it into the site.
  • Reload and retest: After any change, restart or reload the service and rerun the security overview report.

What to check: request each private path directly from an outside network and confirm the response, not only what the admin pages report.

How the web root separates public and private paths

The diagram starts with a browser request reaching the web server, which is configured to serve only the document root. Inside the trust boundary, the document root is the only directory the server maps to URLs. The Moodle code directories and moodledata sit outside that root, so a request for them never reaches the file system through the web server. Check that the server's document root points at the public directory and not the main Moodle folder, then confirm with the security report that private paths are not served.

Only the document root is mapped to URLs; private directories sit outside the trust boundary.

Limits and what to confirm in your environment

Moving the web root and blocking private directories depends on your web server, hosting panel and Moodle version, and each of these can change what is possible. The cards below list the items to verify in your own environment before you treat the layout as safe.

Exact web server configuration

The document root change and the rules that block private directories are written for a specific web server and version. Confirm the syntax for your stack, whether it is Apache, Nginx or another server, and test that a request for a private path returns an error rather than file contents. Keep the configuration under version control so a later change does not silently remove the block.

Moodle 5.1 notes

Hosting panel and container limits

Many shared hosting panels and container images fix the document root to a single folder and do not let you point it at /public. Confirm with your provider or image maintainer whether the document root can be changed, and whether moodledata can be placed outside the web root. If neither is possible, ask whether the platform can deny access to those paths in another way.

Security report checks for your version

The security overview report checks and their wording vary between Moodle releases, so a check that applies to one version may not exist in another. Run the report on your exact version and record which checks test web-accessible paths. Re-run it after every upgrade and plugin install, because a new vendor directory can introduce a new exposure.

Moodle releases

Managed hosting path control

If a managed host or Moodle Partner runs your site, the provider may control the web root, the storage location and the server rules on your behalf. Ask in writing who sets these paths, who can change them, and how they are tested after each platform update. Agree on who receives the results of any path checks and who acts on them.

Dependency and build directories

Vendor and node_modules directories are often copied with the code during deployment, and they can hold test files, examples or configuration that should not be public. Confirm which directories your deployment pipeline copies into the web root and whether your server blocks them. Verify the list after each dependency update rather than assuming earlier builds are clean.

Ownership and file permissions

Path blocks only protect data if the web server user cannot read private directories in the first place and only the intended accounts can write to them. Confirm the owner and permission bits of moodledata and the code tree on your host, and check whether any backup or upload job writes files into a web-reachable location. Document the results so your security team can repeat the check.

Questions buyers ask about moodledata and hardening paths

Can our team secure moodledata and vendor directories without a partner?

Yes, many teams can, provided someone on the team has web server administration skills and can read the security overview report. The core work is confirming that the web server document root points where it should, that moodledata sits outside the web root, and that dependency folders such as vendor and node_modules cannot be fetched by a browser. Each check can be tested with plain HTTP requests from outside the network. The harder part is repeating the checks after every upgrade and plugin install, because a web server change or a new layout can reopen a path. Decide early who owns that routine.

What makes the effort for this work go up or down?

The main drivers are the number of web-facing servers and load balancers, how many different web server configurations exist, and whether the site has custom layouts or reverse proxies that rewrite paths. Existing upgrade debt matters too. A site several releases behind may need its document root changed as part of an upgrade, and the 5.1 move to the /public directory is a layout change, not only a config edit. Plugins that ship their own directories or write files into web-reachable locations add review time. Ask for the number of servers, the proxy chain and the list of installed plugins before accepting an estimate.

What do we need to provide before the work starts?

A partner will usually need four things: administrative access to the web server and reverse proxy configuration, a test environment that matches production closely enough to trust the results, the output of the Moodle security overview report from the site, and a list of the Moodle version, PHP version and database engine in use. Access to the server user accounts that own moodledata and the code directory also helps, because file permissions are part of the review. Agree in writing who makes configuration changes and who approves them, since changes to a live document root can interrupt users.

Does the scope include a retest after the fixes are applied?

That depends on the written scope, so check it before signing. A sound scope should state that the same private paths are requested again after each change, from outside the network, and that the results are recorded against the original findings. Retesting also needs to happen after a Moodle upgrade, a web server change or a new plugin install, because any of these can alter what is served. DeployOpen's security testing work includes retesting as a defined step, and it is worth asking for that step to be listed as a deliverable with a date rather than assumed.

What would a partner deliver at the end of this work?

A typical handover includes the corrected web server and proxy configuration, a short record of which private paths were tested and what each request returned, the security overview report results before and after, and notes on what to repeat after upgrades. Ask for the configuration files themselves, not only a summary, so your team can review and version them. Also ask for the retest results and a plain list of any items left open with the reason. Fixed-scope work should name each of these items in the written scope so acceptance can be checked against it.

How does moodledata placement affect what compliance reviewers will ask for?

Reviewers commonly ask where uploaded files and session-related data are stored and how access to them is restricted. If moodledata is outside the web root and the web server returns errors for direct requests to it, you can show that evidence from the test results. DeployOpen prepares systems, controls and evidence for compliance assessments, but it does not issue audit reports or certifications. The applicable framework, and the exact control expectations, should be confirmed with your auditor or certification body before you decide what evidence to keep.

What happens if a private path is found to be exposed after go-live?

Treat it as an incident with a defined response: block the path at the web server or proxy first, confirm which files could have been read, check access logs for requests that returned content, and then fix the layout that caused it. Moodle security releases arrive on a regular cycle, and a patch can change directory layout, so a check that passed before an upgrade may fail after one. Keep the test requests in a script so the same check can run again quickly. Confirm with your security team how exposure is reported internally and to regulators where your sector requires it.

How DeployOpen confirms paths stay private after go-live

The path review is scoped in writing before any testing starts. The scope lists every host, virtual host and load balancer that serves the Moodle site, the document root each one points to, and the paths to be tested: the moodledata directory, the /public layout where the site runs Moodle 5.1 or later, and any vendor or node_modules directories left in the code tree. It also records which environments are in scope, such as production and any staging copy reachable from the internet. Ask for this scope to name the exact directories on your server, because a dataroot placed under the web root is a different finding from a dataroot placed beside it. Agree in writing who receives the findings and how fixes are verified.

Testing is run from outside your network, the way an outside attacker would approach the site. The tester requests known private paths directly, checks for directory listings and error pages that reveal file locations, and attempts to read files that should never be served. Results from this external pass are compared with the web server configuration, because a site can look correct in the admin interface while a second virtual host or a legacy alias still exposes the tree. DeployOpen runs the Moodle security overview report as part of the same review and records the checks that test these paths, so each finding can be traced to a check the site owner can rerun. Ask whether the report results are included as evidence or only summarized.

The output is a documented web server configuration and a retest. The deliverable records the document root for each site, the rules that block private directories, the commands used to verify them, and any remaining exceptions with reasons. Those records are what your security or compliance team needs to review, and they are not an audit opinion or certification. After go-live, re-checking is set as a retainer item tied to each Moodle upgrade and each plugin install, since a new plugin or a patch can add files or change the document root. Confirm with DeployOpen how often the re-check runs between releases and who signs off on a failed check.

How DeployOpen hardens and verifies Moodle deployments

DeployOpen plans, implements and documents Moodle inside infrastructure you control, so the web server layout that keeps moodledata and vendor directories unserved is designed, built and tested as part of the deployment. The work is scoped in writing before it starts, and the handover gives your security and platform teams evidence they can review and repeat.

How we scope

  • Inventory your Moodle version, web server, PHP setup and whether the site runs on 5.1 or later with the /public document root.
  • Agree in writing where moodledata sits, which vendor and node_modules directories exist, and which paths must return denied responses.
  • Define which security report checks are in scope and which findings need a fix before the site goes live.

How we build

  • Move dataroot outside the web root and set the web server document root to the /public directory where your version uses it.
  • Block direct requests to vendor, node_modules, config and data paths, then test each rule from outside the network.
  • Re-run the security overview report after the change and record each check that still needs attention.

How we hand over

  • Deliver the web server configuration, the directory layout and a written list of tested paths with expected responses.
  • Document the security report findings, the fixes applied and any items you accepted with a stated reason.
  • Walk your administrators through the checks to repeat after upgrades, plugin installs and server changes.

How we support

  • Engagements are fixed-scope, with scope, deliverables and timelines agreed in writing before work starts.
  • Ongoing support, upgrades and continuous testing are available as a retainer, which can cover re-checking paths after each Moodle release.
  • Ask for a quote built from the written scope, including what you own after handover and what recurs under a retainer.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.