Not sure if this is possible at all, but maybe there's another way to go about this that will get the same result.
The old situation
I'm running a LAMP server with CentOS 6. This server hosts a LOT of websites that we own. In the file system, we have a folder with all the assets that are common to these websites (images, audio files, etc). We're talking around 400K files and 60 GB of data.
The way the websites access that folder is via a symlink called assets placed in the root of their respective document root (so basically there are dozens of these assets symlinks spread out throughout the file system), so the code of all those websites is full of references to those symlinks in order to load those files in their pages.
Let's say that assets symlink points to /server/path/to/assets
. Websites load a file calling, for example, http://mywebsite.com/assets/audio_file.mp3
.
Internally, the assets symlink loads the file located at /server/path/to/assets/audio_file.mp3
.
The new situation
We have decided to move that assets folder off the server, to another location in the internet (AWS S3 if anyone's curious), to save some space in the server and reduce the load.
The issue
Since we're moving the location of those assets, we would need to manually change all the references to those assets in the code of all the websites. That's a LOT of work of course, we're talking thousands of them.
There's the option of using search and replace in the code of all the websites, which I will do if there isn't any other way, but for different reasons I would prefer to avoid that if possible.
The ideal solution
What I had in mind, ideally, would be something as simple as creating a symlink where all the current symlinks point to, and make that point to the URL of our AWS S3 bucket. Something like:
- Remove the
/server/path/to/assets
folder (after having moved all the files from there of course) - Create a new symlink (or whatever other solution would work here) called assets instead of the folder that points to
https://my-amazon-s3.com/assets
And then, magically, when a website wants to load http://mywebsite.com/assets/audio_file.mp3
, it looks for the file in the AWS S3 bucket and not our server.
I know this might be a bit too much to ask, so I was hoping that maybe there's another way I could solve this problem that someone may suggest.