feature: the router serves S3-compatible object storage with versitygw, with one S3 account per user and buckets owned by users.
Release / release (push) Successful in 14s

This commit is contained in:
slawek committed 2026-10-29 19:24:24 +01:00
1 parent d99e4ea425
commit 1eac15e640
20 files changed
+1115 -25

No files matched your search

+83
View File
@@ -147,6 +147,9 @@ must have the type shown below; an unknown section or setting is an error.
| `sites` | `upload_max_mb` | integer | `512` | The largest upload of a site's file or zip archive, in MiB, 1 to 10240 |
| `sites` | `webdav` | boolean | `false` | WebDAV of the sites' folders, which needs `https.enabled` and `wan.local_fqdn` (see WebDAV) |
| `sites` | `webdav_port` | integer | `7445` | HTTPS port of WebDAV |
| `s3` | `enabled` | boolean | `false` | S3-compatible object storage, which needs `https.enabled` and `wan.local_fqdn` (see Object storage) |
| `s3` | `port` | integer | `7447` | HTTPS port of the object storage |
| `s3` | `region` | string | `us-east-1` | The region S3 clients sign their requests with |
| `dns` | `enabled` | boolean | `false` | The primary name server of the router's domains, which needs `dns.nameserver` and `dns.addresses` (see Name server) |
| `dns` | `nameserver` | string | | The name server's host name, the primary NS of every domain |
| `dns` | `addresses` | list | | The public addresses of the name server, the domains' apexes and the sites' host names |
@@ -188,6 +191,7 @@ must have the type shown below; an unknown section or setting is an error.
| `backup` | `keep_monthly` | integer | `12` | Monthly local archives kept |
| `backup` | `keep_yearly` | integer | `0` | Yearly local archives kept |
| `backup` | `metrics` | boolean | `false` | The backup holds the database of the metrics and the refresh tokens |
| `backup` | `s3` | boolean | `false` | The backup holds the buckets of the object storage too; its accounts are always held |
| `backup` | `rclone_remote` | string | | `remote:path` of `/etc/vpn-router/rclone.conf` the local archives are copied to |
| `backup` | `rclone_mode` | string | `sync` | `sync` mirrors the archives, `copy` deletes nothing in the cloud |
| `backup` | `pbs_repository` | string | | `user@realm!token@host[:port]:datastore` |
@@ -1674,6 +1678,85 @@ vpn-config-edit set dns.addresses 203.0.113.10
vpn-config-edit set --restart dns.enabled true
```
## Object storage
While `s3.enabled` is `true` and HTTPS is ready, the router serves S3-compatible object storage
at `https://<wan.local_fqdn>:<s3.port>` (7447 by default), with path-style addresses, for clients
such as `aws s3`, rclone, restic or Terraform's `s3` backend. The firewall opens the port where it
opens the other HTTPS ports.
```sh
vpn-config-edit set --restart s3.enabled true
```
**The service**
- **The server:** versitygw, pinned to one release, which a release of vpn-router raises.
`vpn-router-install@s3.service` downloads its `.deb` for amd64 or arm64 from GitHub, checks its
SHA-256 and installs it with apt-get, when another version or none is installed.
- **How it runs:** `vpn-router-s3.service` runs it as root, sandboxed. Its S3 API is on
`127.0.0.1:7448`, which Caddy serves, and its Admin API on `127.0.0.1:7449`.
- **Storage:** with the POSIX backend, each folder of `/var/lib/vpn-router/s3/data` is a bucket
and the files below it are its objects.
- **Settings:** `/etc/vpn-router/s3.env` (0600, written by setup) holds the root keys, the ports,
the IAM folder `/var/lib/vpn-router/s3/iam` and `s3.region`, which clients sign with.
**Accounts**
- **One account per user:** a user or service account of the directory has at most one S3
account, an access key and its secret.
- **The secret is shown once,** when the account is made or its secret replaced.
`/etc/vpn-router/s3-accounts.json` (0600) records the accounts with their owners.
- **Following the user:**
- while the user is disabled, the account's secret is replaced by an unknown one;
- once the user is enabled, the account has its own secret again;
- removing the user removes the account.
Setup brings every account in line at each run.
**Buckets**
- A bucket belongs to one account, which alone may use it.
- Buckets are made, given to another user and removed (when empty) by an admin.
- A user's buckets keep the account as their owner after the account is removed, until another
owner is chosen.
```sh
vpn-router-s3 account add alice # prints the access key and the secret once
vpn-router-s3 bucket add tfstate --owner alice
aws --endpoint-url https://router.example.com:7447 s3 ls s3://tfstate
```
| Command | What it does |
| --- | --- |
| `vpn-router-s3 status` | Whether storage is on, the installed and the pinned versitygw, whether it runs, the endpoint and the region |
| `vpn-router-s3 account list [--owner U]` | The accounts with their owners and the time each was made |
| `vpn-router-s3 account add\|rotate\|remove U` | Make the user's account, replace its secret, or remove it |
| `vpn-router-s3 bucket list` | The buckets with their owners, sizes and numbers of objects |
| `vpn-router-s3 bucket add NAME --owner U` | Make a bucket of the user's account |
| `vpn-router-s3 bucket owner NAME U` | Give the bucket to another user's account; versitygw resets its ACL and policy |
| `vpn-router-s3 bucket remove NAME` | Remove the bucket, which must be empty |
`vpn-router-s3` answers JSON with `--json`, as `vpn-router-site` does.
**Web service API** (`/s3` for admins, `/account/s3` for the signed-in user)
| Request | Body | Answer |
| --- | --- | --- |
| `GET /s3` | | `{"settings", "endpoint", "version", "installed", "running", "buckets", "accounts", "problem"}` |
| `PUT /s3` | any of the `s3` settings | `{"settings"}`, applied by setup |
| `POST /s3/buckets` | `{"name", "owner"}` | `{"name", "owner"}` |
| `PUT /s3/buckets/<name>` | `{"owner"}` | `{"name", "owner"}` |
| `DELETE /s3/buckets/<name>` | | `{"name", "removed": true}`; 409 while it is not empty |
| `POST /s3/accounts` | `{"owner"}` | `{"owner", "access_key", "secret_key", "created"}` |
| `PUT /s3/accounts/<owner>` | | the same, with a new `secret_key` |
| `DELETE /s3/accounts/<owner>` | | `{"owner", "access_key", "removed": true}` |
| `GET /account/s3` | | `{"enabled", "endpoint", "region", "account"}`, `account` null without one |
| `POST`, `PUT`, `DELETE /account/s3` | | Make, replace the secret of, or remove the user's own account |
Backups always hold the IAM folder and `/etc/vpn-router`; with `backup.s3` they also hold the
buckets, which may be large.
## Metrics
While `metrics.enabled` is `true`, `vpn-router-setup` runs `vpn-router-metrics`, which every minute