A caching and coalescing MITM (Man-in-the-Middle) HTTP(S) forward proxy with an embedded dashboard.
Supports caching of both HTTP and HTTPS requests by injecting a certificate to decrypt and cache the data before sending it back to the client.
The original intended usage is as a central cache proxy for apt or other package managers when spread across multiple containers.
The dashboard is directly embedded into the executable, so the final build artifact is a single self-contained executable.
To start with, you need to generate a CA certificate and key to be used as your own makeshift certificate authority to generate new certificates for requests to HTTPS domains. This is the mechanism that allows the proxy to decrypt and cache HTTPS responses, with the caveat being that EVERY client that proxies HTTPS requests through this MUST trust this CA certificate, otherwise you will get errors relating to the untrusted cert.
This generates a CA certificate with the common name (CN) "reservoir" and corresponding key, both in PEM format.
openssl genrsa -out ca.key 2048
openssl req -x509 -new -nodes -key ca.key -sha256 -days 3650 -out ca.crt -subj "//CN=reservoir"
/usr/local/share/ca-certificates/ and run sudo update-ca-certificates.ca.crt, click "Install Certificate..." and follow the wizard.To run the proxy you have two options; you can either download a prebuilt binary from the releases page (or an unstable build from the actions page), or you can build it yourself by following the instructions below:
Before getting started, you will need to install a few dependencies:
First off you will need to have Node.js installed and pnpm enabled (run the command corepack enable pnpm).
Then you need to have GNU make installed. The way to do this will vary depending on your OS. If you use a Linux distro it will be easy to install via your package manager (it might even be preinstalled).
On Windows the easiest way to do this is with Chocolatey by running choco install make.
Alternatively you can install it manually here.
You will of course also need to have Go installed.
Then you just have to build the project with make by running make in the project directory.
This will automatically build the frontend and the final proxy executable.
The resulting executable is now ready in the project root to be copied standalone to wherever you wish.
If you are running it on Linux, you can also setup a systemd service for it, which is recommended.
Configuration can be done either via the generated configuration file, or the command-line arguments.
If a setting is both specified in the configuration file and as a command-line argument, the command-line argument will take precedence.
The configuration file is a JSON file that contains all the settings for the proxy.
You can edit this file manually in var/config.json to change the configuration. If the var/ folder or config does not exist, run the proxy once, and it will be created automatically.
Some settings can also be changed in the Dashboard.
When the API and dashboard are enabled and the user database is empty, Reservoir starts in first-run bootstrap mode.
The first admin username can be chosen during setup. The bootstrap password must be at least 12 characters, is never written to disk, and the created user is signed in immediately after setup. Once a user exists, the bootstrap endpoint returns a conflict and normal login is required.
If the API is disabled, Reservoir cannot create dashboard users or accept dashboard logins.
Reservoir is tuned first as a shared package cache for package-manager traffic. By default the proxy cache policy favors useful package caching over strict upstream cache directives:
proxy.cache_policy.ignore_cache_control defaults to true, so package responses can still be cached when upstream sends directives such as no-store.proxy.cache_policy.force_default_max_age defaults to true, so cached responses use proxy.cache_policy.default_max_age instead of upstream freshness metadata.Authorization or Cookie are not stored in the shared cache.Set-Cookie, unsupported Vary, or unsafe content encoding metadata are not stored in the shared cache.These defaults are intentional for package-cache deployments. If you need stricter general-purpose proxy semantics, disable ignore_cache_control and force_default_max_age in var/config.json.
Reservoir supports three cache backends:
cache.type = "memory" keeps cached responses in process memory. This is the default and is best for short-lived burst caching where the proxy only needs to coalesce many package-manager requests that happen close together.cache.type = "file" stores cached response bodies under cache.file.dir. This is useful when cached package responses may be larger than the memory budget or when short restart continuity is useful.cache.type = "hybrid" keeps new and recently accessed responses in memory first, then demotes entries that have not been accessed for cache.hybrid.demote_after to the file cache. A later file-cache hit is promoted back into memory when it fits. This keeps bursty package-manager traffic fast while still giving colder entries short restart continuity.The file cache writes metadata sidecars next to cached response bodies. On startup, Reservoir loads sidecars only when the matching cached body still exists, the body is non-empty, and the cached response has not expired. Expired, corrupt, or orphaned cache files are discarded. This preserves useful restart continuity without turning the proxy into a long-lived package repository.
Loaded file-cache entries are still subject to cache.max_cache_size, normal expiry, and the cleanup interval. If restored entries exceed the configured cache size, startup eviction trims them before serving traffic.
You can always display info about the command-line arguments by running the proxy with the --help flag. Command-line arguments only override the generated configuration when they are supplied.
The command-line arguments currently available are the following:
Other cache settings are currently configured through var/config.json or the dashboard rather than command-line flags. The most important ones are:
cache.type - memory, file, or hybrid.cache.max_cache_size - Maximum total cache size.cache.cleanup_interval - How often expired entries and over-budget cache data are cleaned up.cache.memory.memory_budget_percent - Memory-cache budget as a percentage of total system memory.cache.hybrid.demote_after - How long an entry can sit in hybrid memory storage without access before being moved to file storage.proxy.cache_policy.ignore_cache_control - Whether to ignore upstream cache-control directives.proxy.cache_policy.force_default_max_age - Whether to always use Reservoir's configured default freshness lifetime.proxy.cache_policy.default_max_age - The fallback/default freshness lifetime for cached responses.curl -x http://127.0.0.1:9999 https://example.com/
If your CA is not trusted by the system, you can specify it for curl:
curl --cacert ca-cert.pem -x http://127.0.0.1:9999 https://example.com/
Alternatively if you are too lazy to specify the cert (like me), you can use the -k option to skip cert validation:
curl -k -x http://127.0.0.1:9999 https://example.com/