I’ve been wondering about making an rclone plugin for caddy.
rclone has interfaces to >20 cloud providers which it would be nice for caddy to be able to serve or use as input to any of the other plugins.
rclone can provide an http.FileSystem which caddy could use as it’s root file system.
Being #lazydev I tried to find another plugin which does this but I failed, which made me wonder whether this is possible or not? I didn’t see this type of plugin listed on the plugins page.
rclone needs a bit of internal re-organisation to make this possible (so it is more usable as a library) but making a plugin for Caddy would be good motivation for me to get this work done.
So, is this possible? And apologies in advance if I failed to find the documentation.
Hi Nick! Great to have you here. (No worries, we don’t have great docs yet. It’ll happen someday!)
Yep, this is possible, and sounds like a neat idea. Let me know if this sounds right: So you could use, say, an rclone directive to “proxy” requests directly to cloud storage (or any of rclone’s supported providers). In other words: upload your site to your Dropbox or S3 and then serve those files via Caddy, instead of the files being local to the machine Caddy is on.
The browse directive also makes a staticfiles.FileServer, so you could even say browse in your Caddyfile and have it serve its listings through rclone.
use rclone mount to mount the remote filesystem and serve it with caddy - this is how I serve beta.rclone.org
use rclone serve http or rclone serve webdav and proxy those via caddy (I haven’t actually tried this but it should work!)
However all of those suffer from their being unnecessary set of requests going on, either filesystem requests via FUSE through the kernel back and forth to rclone or HTTP requests.
I see! Yes an existing browse-like plugin would fit into the caddy plugin scheme as it stands…
Ah ha! I tried to find that bit of code but I didn’t succeed
What the plugin needs to do is provide a replacement for http.Dir(site.Root) in that line.
What I might try is a hideous bodge to see if I can get something working then we can discuss a better way of doing it! Unless you have an idea of how to start out initially?
Since I’m some way from re-architecting rclone so it would actually work as a library I might just do a test file system as a proof of concept.
I don’t have a great design idea at the moment, but I will say that it’s not uncommon for plugins to import each other (as long as there’s no cycles of course!) – the staticfiles plugin stands pretty much on its own, so it can be imported. Your plugin could potentially import the browse plugin and register itself as a plugin to the plugin, as a backend for browse.
I hope that made sense.
Anyway, yeah, feel free to go for it! I will be happy to take a look at the PR. No hurry of course. It’s neat you’re thinking about it.