Serving static files (i.e. images) from another domain (static.mywebsite.com)

Hi,

I’m new to ghost and spent the last few hours reading almost the whole documentation. Most things are clear but I’m wondering if it is possible, to insert all images (and in the best case static template files like css, js as well) from another (absolute) url?

I really would like to use an s3 compatible storage to store all assets. There’s the s3 storage driver for that. But as far as I could see in it’s code it will, for every uncached request, request the file from the object storage (over network) and then deliver it (over network again). What I want is that all assets are stored via the s3 storage driver but are embedded into the pages not by a relative path like content/images/2020… but instead by a custom set domain like https://static.mywebsite.com/content/images… so I can put a CDN in front of the object storage and deliver static assets without having ghost involved. I know that I could instead put cloudflare in front of my whole page and let it deliver all assets but I really would like to use another CDN for the heavy lifting and I would like to seperate the server running ghost from the asset storage.

What I found is https://forum.ghost.org/t/is-there-anyway-to-separate-the-static-files-domain-from-the-html/959 but as I read the source code of the s3 driver I don’t think that just using the driver helps to archieve what I want.

Is there any possibility to accomplish that?

Thanks in advance

Joshua

Hey Joshua :wave:
At first I thought you were just looking to host your images on another server. But after reading more carefully it seems you’re after storing pretty much everything on static hosting with the aim to get the best loading performance, is that right?

If so then I’d highly recommend using Ghost as a Headless CMS and the JAMstack approach. This method of building sites means that all your assets are hosted statically from wherever you like! Images, CSS, JavaScript and even the HTML can be on your own hosting while still getting the benefit of the Ghost editing experience. Check out some of our starters for Eleventy and Gatsby:

We also have documentation on using Ghost with a wide selection of other static site generators:

I realised this is a fairly different approach to how you’ve described, but I think this is a configuration that would fully cover what you’re wanting :slight_smile:

Any questions feel free to ask :v:

Hey
thank you for your reply. You’re right, performance wise this would be the optimal way. But with that the setup would get pretty complex and I really want to keep ghost because of its current and maybe upcoming features, i.e. the subscriptions and I also read that ghost might get its native comment feature in the future. The only thing I want is really the opportunity, to configure which url goes into the database if I upload a new image (i.e. not the relative path but an absolute one like I described above). This would be supercool especially because then one can make full use of the storage drivers like the s3 one. I mean, what is more intuitive than serving the images from the place where they’re stored (i.e. s3) instead of pulling them from s3, piping them through node, maybe through an nginx reverse proxy as well and serving them then instead of having the opportunity to simply embed the image by its s3 url (or a cdn in front of that)?