Storing WordPress Media Library Uploaded files onto a separate domain

We are looking forward to offload assets from our website (60GB onto a 8TB/mo accessed website), to a separate webserver that will be there only for serving images from a separate domain.

I know that I can apply filters to match /wp-content/uploads and rewrite these URLs in order to point at the new domain, but I have no way to have the Media Library Uploader to upload files straight to the new server.

Of course, I can provide SSH/Rsync and relative access between two servers. There are a few plugins that do the same for Buckets like AWS/Google Cloud and they do take care of removing the file locally, but the comparison of the services’ price between an owned machine and these services showed big difference, so we ended up in developing our own solution.

Can anyone advise on how I can have Media Uploader to work with a different host?
I thought that this was already implemented using a defined constant in wp-config, but thats untrue.

1 Answer

You should not remove the media from you server. Media is part of yout content and it makes no sense to have your content split over several servers.
(from technical practical POV your idea will prevent any automated media transformation like new sizes from being done).

What you should do is to create your own “lite CDN” which is actually just a sort of caching proxy for the media related URLs.

(side note: you can rarely re-invent a wheel for your car which is cheaper than a wheel you can buy in a shop)

Leave a Comment