Load files outside htdocs



I was using Nanobox to bootstrap my local development environments. I never face problems with that tool and until I wanted to use cron jobs locally with Moodle LMS. I found this project “DevilBox” and tested it with simple applications which made me decide to use it with all my Moodle projects. The problem I am facing is with “moodledata” folder. This folder must be outside of the public website root, where Moodle upload files, cache files, create temporary files, save sessions files and of course serve cached files from it like theme related files, media and so on.
The problem I am facing now is after installation, Moodle can’t serve files from this folder. It can create files in it but not serve them and I receive 303 error for all files from this folder. I tried to use custom Vhost to configure Nginx as Moodle recommend in their documentation, but same error persists. To be honest, I am out of options now, I don’t know what’s the problem exactly is it an Nginx problem or privileges?
Can someone give me a good reason why this is happening?


Have a look at the current examples how the www (or whatever it is called per framework) directory is actually symlinked to htdocs. This way everything else can stay outside:



Yep I tried that too, but unfortunately still the same issue. But this is different from other frameworks, all the code must be under the public directory and that’s where the index.php reside.
Now I am using the structure below, all Moodle files reside inside htdocs and this is how Moodle want them. The only thing that must be outside is moodledata. And this is what I get


I dont see any public directory. Can you do a tree -L 2


The public directory here is the htdocs itself. Moodle is like Wordpress, but it needs moodledata outside the www or public_html or here outside htdocs.


You will probably have error logs in case of issues. Either Devilbox (Nginx in this case) or moddle logs itself.

Apart from that, what would be a normal (non-Devilbox related) setup of moddle?


Generally sounds like a difficult one, so I’d suggest we work it out together and I will file another example documentation covering Moodle.


I tried it with Apache and it’s working perfectly now. So, I think the problem is with Nginx configuration. I will write how to setup Moodle with Apache and try to find a solution for Nginx or the best configuration to work with it. And create a pull request for it so you can check it or publish it. Of course if don’t mind me contributing :slight_smile: .


@mohessaid You can use the docker-compose.overrides.yml file to mount any folder or files into the php container:

      - /real/path/to/moodledata/:/shared/httpd/sap.zad/moodledata/

Instead of having a symlink in the sap.zad/moodledata


I think its quite the opposite. Feedback is very much welcome as this project should also be shaped by the community into a direction the community wishes to go. So please create your PR. :slight_smile:


Keep in mind that there will be some up-coming changes when using docker-sync: https://github.com/cytopia/devilbox/pull/535

This will introduce another file (only used if using `docker-sync) where mount points will be defined: https://github.com/cytopia/devilbox/blob/db9d3a9405eac905156d70fa7128d9da82ad6325/docker-sync.yml