Implement an easy solution for hosting a community mirror
This issue supersedes mlugg/setup-zig#15. Currently, the easiest way to set up a "community mirror" of Zig tarballs is using Mach's Wrench. It works well, but is written in Go and part of a more monolithic program. It'd be good to have a more minimal solution to point to.
So, someone should make one! It should expose an HTTP server locally, take requests for files, and cache them in a given directory, with some reasonable eviction policy. SSL is out of scope for this project; a local web server can be used to rproxy to the mirror software instead.
I reckon this should be pretty easily doable in a couple of hundred lines of Zig.
This need not be an official ZSF project; this issue is just to track the creation of something along these lines.
While not exactly what this issue is asking for, I have implemented my own solution for running https://zig.squirl.dev, based on bunny.net's CDN, using edge scripts for routing. The setup is pretty simple, and documented here.
Unfortunately it's pretty tied to bunny.net, but it could serve as inspiration for other CDN-based solutions :)
Example configuration for Varnish with the Fastly CDN: https://fiddle.fastly.dev/fiddle/97803f6c
This depends on progressing our fuzzing toolchain, and then doing fuzzing against std.http and std.crypto.tls. Otherwise users are looking at security vulnerabilities.
I have also rewritten http client and server API in a branch. still not happy with it but it's better than status quo
I've built an application for this specific purpose - to provide the simplest possible way to create a Zig community mirror:
- https://github.com/SavaLione/go-mirror-zig/
I've also created a pull request #536 in case the application is worth mentioning there.
I believe that a solution written in Zig would suit this purpose better, but I'm not confident enough in my Zig skills, so I used Go.
Due to Nginx's support for regex, it is theoretically possible to use Nginx as a caching proxy (with 'Certbot' for automatically obtaining certificates) and a bash script with curl, but I haven't dug deep into that approach.