Summer Sale! All accounts are 50% off this week.

vercoutere's avatar

Multi tenant separation of assets

This isn't really Laravel specific, however I'm currently building my app on Laravel so maybe there's something, somewhere in the framework that can help me out.

There's a lot of discussion on the internet about database architecture when designing multi tenant applications.

What I can't find any information about is what would be the best practices to separate assets.

Let me give an example:

Using the default Laravel folder structure we'd place all images in a subdirectory of the public directory.

Let's assume we have two websites called website1 and website2 and this is the directory structure we have in our public folder:

public

--- website1
------ img
------ css
------ js

---website2
------ img
------ css
------ js

This would all work fine, but you could request and image for website1 by visiting something like website2.com/website1/img/image.jpg.

Obviously this isn't something we want in a multi tenant environment.

So my question is:

How do you go about separating assets in a multi tenant environment.

0 likes
3 replies
luceos's avatar

Seeing this question wasn't answered. I solved this issue in my package by using alias functions in both nginx and apache configurations. Using alias you can link a subfolder (for instance media) with any path of your installation per hostname. So website2.com/media would point to the img folder of website2.

1 like

Please or to participate in this conversation.