Use Netlify as HTTPS proxy for Storj decentralized Object Storage

Hi everybody!
I am currently hosting my personal website at tommispace.netlify.app. I am placing inside the original website repository the few media files that go with it, and they amount to some 100MB.

Both to reduce the heaviness of my website repository, keeping it shy of media files, but above all to have a future-proof convenient LFS solution, I intend to serve bigger files through Storj Object Storage, that is awesome. Nevertheless, in Storj’s guide to host a static website (hence to host media files, too), it points out that a proxy server is required in order to ensure HTTPS connection:

  1. Without further action, your site will be served with HTTP. You can secure your site by using an HTTPS proxy server such as Fastly.

Is there any way Netlify could help me with this?
Rather than having to rely on a complex system of proxies or serving resources through HTTP, I would stick with my current solution, but I really would prefer to implement Storj.

Any suggestion would be extremely helpful. Please bear in mind that unfortunately I am not a developer, and I could not, for instance, develop a plugin to carry out this task.

Thanks a lot!
Tommi

It can be achieved with Netlify rewrites:

Basically, a rewrite rule like:

/storage/* http://www.example.com/:splat 200! would do the trick.

1 Like

Thanks a lot, @hrishikesh, this is awesome and super useful! Can I ask you where should I write the redirect rule in?

Furthermore, is there a way I can redirect any resource URL to the root of my domain, regardless of the subdirectory they originally were in?

e.g. I would like to have http://assets.tommi.space/images/example1.jpg and http://assets.tommi.space/videos/example2.mov respectively available as https://tommi.space/example1.jpg and https://tommi.space/example2.mov

Would it be possible?

Sorry, some further problem… I both tried adding a _redirects file with this content

#/* http://assets.tommi.space/:splat 200!
/audio/* http://assets.tommi.space/audio/:splat 200!
/fonts/* http://assets.tommi.space/fonts/:splat 200!
/graphics/* http://assets.tommi.space/graphics/:splat 200!
/images/* http://assets.tommi.space/images/:splat 200!
/svg/* http://assets.tommi.space/svg/:splat 200!
/video/* http://assets.tommi.space/video/:splat 200!

and a netlify.toml with:

[[redirects]]
	from	= '/assets/*'
	to		= 'http://assets.tommi.space/:splat'
	status	= 200
	force	= true

In both cases, nothing works… you could reproduce the error with the file http://assets.tommi.space/images/zattere.jpg

Ok, so apparently the error lied in the ', TOML files only accept ".
It now works!

Sorry if I ask for more, but could you tell me how I can cache the assets properly?

By running a test, as you can see here, I should be able to cache the files served via 200

Could you help me, @hrishikesh? If needed I could create a new thread.

Hey @tommi,

To cache files, the appropriate cache control headers need to be sent by the destination server. We respect those headers and cache accordingly. If you cannot control the caching headers on the destination server, there’s not a lot you can do.