I am new to Craft 3 and I have seen similar questions asked many but never answered.
I want to store my images in a directory that is not public, yet I want them to be served correctly by Craft. The reason why I am doing this is that I work with shared disks for EC2 instances in AWS (Not S3) so I need to be able to mount shared volumes to store images for all the Front Ends to serve.
I am experimenting (without mounting a disk, to simplify) and I have a volume with:
name: images handle: images Assets in this volume have public URLs: on Base URL: @web/somestuff Volume Type: local folder File System Path: /var/www/mydomain.com/imagesrepo
Note that the directory /var/www/mydomain.com/imagesrepo has 777 rights, images are uploaded correctly in the CMS, and even "image transform" correctly creates subdirectories and resizes images. I see the images thumbnails but, following the problem explained below, the image shows a broken when I click on "preview".
Also note that in the directory tree, imagesrepo is outside the website root, at the same level with the "web", "config", etc... directories for Craft. (/var/www/mydomain.com/web is the website root)
I have installed "element api" and I am getting the URL of the image with
and a "resized" version with
The result URLs I am getting are
The URLs look correctly built and I would expect that, once called, Craft would fetch the image file with the actual disk location in /var/www/mydomain.com/imagesrepo and read it out to the front end. Instead I get a 404 page with
HTTP 404 – Not Found – yii\web\NotFoundHttpException
and the whole stack trace, as if Craft was trying to find "somestuff" as a regular template.
Am I doing something wrong or is Craft not able to store assets in a physical location and serve them from a logical one?
P.s. Please do not tell me that there are drivers and plugins for AWS solutions. There are many reasons to store assets in physical locations that differ from the URL