v0.40.0
This commit is contained in:
1 parent
3b5fc8dce1
commit
748fe1d146
23 files changed
+2901
-40
No files matched your search
+222
-5
@@ -15,7 +15,10 @@ Available since 0.38.0.
|
||||
| Listeners | must be declared in the configuration | taken from `--proxy-listen` / `--tls-listen` when the file declares none |
|
||||
| Vhost `frontend.listener_ids` | required | optional; defaults to every enabled listener |
|
||||
| GeoIP downloads | on by default | off unless the file sets `geoip_updates` |
|
||||
| ACME issuance and auto-renewal | panel and renewal pipeline | not available; use external certificate files (for example Certbot) |
|
||||
| ACME issuance and auto-renewal | panel and renewal pipeline | `headless.acme` / `--acme-domains`, `--acme-auto` (since 0.40.0); state in `<data-dir>/certs/headless-acme.json` |
|
||||
| Certificate files | import in the panel | `headless.tls` / `--tls-cert-file`, `--tls-cert-dir` (since 0.40.0) |
|
||||
| Configuration file | optional | required, unless `--route` is used (since 0.40.0) |
|
||||
| Automatic reload on file change | — | `"watch": true` / `--watch` (since 0.40.0) |
|
||||
| Software update check | on | off |
|
||||
| Health endpoint | optional `--health-listen` | optional `--health-listen` |
|
||||
|
||||
@@ -31,7 +34,7 @@ Headless mode reads the **same configuration format** as the panel mode: every s
|
||||
| `frontend.listener_ids` of a vhost, redirect or 404 host | every enabled listener |
|
||||
| `geoip_updates` | `{"enabled": false}` |
|
||||
|
||||
Anything you write explicitly is kept. A configuration exported from the panel (about 176 KB, 31 vhosts, cache rules, Docker agents) was tested unchanged in headless mode, both on a copy of its data directory and on an empty one.
|
||||
Anything you write explicitly is kept. One extra top-level object, `"headless"`, holds headless-only settings (certificate files, ACME, `watch`); see [HTTPS](#https-certificate-files-and-automatic-certificates). A configuration exported from the panel (about 176 KB, 31 vhosts, cache rules, Docker agents) was tested unchanged in headless mode, both on a copy of its data directory and on an empty one.
|
||||
|
||||
### From an existing panel installation
|
||||
|
||||
@@ -149,7 +152,220 @@ Point the certificate at the lineage and reload RustProxy after each renewal:
|
||||
systemctl reload rustproxy
|
||||
```
|
||||
|
||||
The service account needs read access to the files and the directories must pass the trusted-path checks; see [Certificates: existing local files](CERTIFICATES.md) and [Installation: external paths](INSTALL.md#linux-debrpm-read-only-access-to-external-paths). Certbot's DNS-01 plugins work without touching RustProxy. HTTP-01 needs `/.well-known/acme-challenge/` on port 80 to reach Certbot, for example a route with a Web Service that serves the Certbot webroot.
|
||||
The service account needs read access to the files and the directories must pass the trusted-path checks; see [Certificates: existing local files](CERTIFICATES.md) and [Installation: external paths](INSTALL.md#linux-debrpm-read-only-access-to-external-paths). Since 0.40.0 the same is simpler with `--tls-cert-dir /etc/letsencrypt/live` (no JSON entry per domain) or without external Certbot at all with `--acme-domains`; see [HTTPS: certificate files and automatic certificates](#https-certificate-files-and-automatic-certificates). Certbot's DNS-01 plugins work without touching RustProxy. HTTP-01 needs `/.well-known/acme-challenge/` on port 80 to reach Certbot, for example a route with a Web Service that serves the Certbot webroot.
|
||||
|
||||
## HTTPS: certificate files and automatic certificates
|
||||
|
||||
Since 0.40.0 HTTPS can be set up without `tls.certificates` entries: certificate files, whole certificate directories and automatic DV certificates from Let's Encrypt (ACME). Every setting can be written **in the JSON file** (a top-level `"headless"` object) **or** given **on the command line / in `/etc/rustproxy/environment`**; both are merged on every start and reload. RustProxy still never writes the file.
|
||||
|
||||
Host names come from the certificate's subject alternative names (SAN): a vhost whose host the certificate covers serves it automatically, without `certificate_id`. An explicit binding (`hosts` of a certificate or a vhost `certificate_id`) still takes precedence. Clients that send no SNI, or a name no certificate covers, get `tls.default_certificate` (self-signed unless set). All of this needs an HTTPS listener (`--tls-listen 0.0.0.0:443` or an `https` listener in the file); a warning is logged when there is none.
|
||||
|
||||
### The `"headless"` section
|
||||
|
||||
The section is read only in headless mode and removed before the rest of the file is read, so the remaining file keeps the normal configuration format (the panel refuses a file that still contains it). Relative paths are relative to the configuration file.
|
||||
|
||||
```json
|
||||
{
|
||||
"headless": {
|
||||
"watch": true,
|
||||
"tls": {
|
||||
"certificates": [
|
||||
{ "cert_file": "/etc/ssl/app/fullchain.pem", "key_file": "/etc/ssl/app/privkey.pem" }
|
||||
],
|
||||
"directories": ["/etc/letsencrypt/live"]
|
||||
},
|
||||
"acme": {
|
||||
"email": "ops@example.com",
|
||||
"agree_tos": true,
|
||||
"staging": false,
|
||||
"provider": "http01",
|
||||
"dns_credentials": "/etc/rustproxy/cloudflare.ini",
|
||||
"propagation_seconds": 60,
|
||||
"renew_days": 30,
|
||||
"auto": true,
|
||||
"domains": [
|
||||
["app.example.com", "www.app.example.com"],
|
||||
"api.example.com"
|
||||
]
|
||||
}
|
||||
},
|
||||
"vhosts": [ ... ]
|
||||
}
|
||||
```
|
||||
|
||||
| JSON (`headless.…`) | Command line | Environment | Meaning |
|
||||
|---|---|---|---|
|
||||
| `tls.certificates[].cert_file` / `key_file` | `--tls-cert-file` / `--tls-key-file` | `RUST_PROXY_TLS_CERT_FILE` / `RUST_PROXY_TLS_KEY_FILE` | Certificate chain (leaf first) and its private key. Repeatable; on the command line paired by position, comma-separated in the environment. |
|
||||
| `tls.directories[]` | `--tls-cert-dir` | `RUST_PROXY_TLS_CERT_DIR` | Directory scanned on every start and reload (layouts below). |
|
||||
| `acme.domains[]` | `--acme-domains` | `RUST_PROXY_ACME_DOMAINS` | Names of one certificate: a JSON list or a comma-separated string. Repeat for more certificates; in the environment separate certificates with `;`. Up to 32 certificates with 16 names each. |
|
||||
| `acme.auto` | `--acme-auto` | `RUST_PROXY_ACME_AUTO=1` | Also request a certificate for every vhost/redirect host that no other certificate covers ([below](#automatic-certificates-for-every-vhost-acmeauto)). |
|
||||
| `acme.email` | `--acme-email` | `RUST_PROXY_ACME_EMAIL` | ACME account contact (required). |
|
||||
| `acme.agree_tos` | `--acme-agree-tos` | `RUST_PROXY_ACME_AGREE_TOS=1` | Accept the Let's Encrypt Subscriber Agreement (required). |
|
||||
| `acme.staging` | `--acme-staging` | `RUST_PROXY_ACME_STAGING=1` | Let's Encrypt staging CA (untrusted test certificates). Default: production. |
|
||||
| `acme.provider` | `--acme-provider` | `RUST_PROXY_ACME_PROVIDER` | `http01` (default), or DNS-01 with `cloudflare`, `ovh`, `rfc2136`. Wildcards need DNS-01. |
|
||||
| `acme.dns_credentials` | `--acme-dns-credentials` | `RUST_PROXY_ACME_DNS_CREDENTIALS` | Certbot plugin credentials file for DNS-01, mode `0600`. |
|
||||
| `acme.propagation_seconds` | `--acme-propagation-seconds` | `RUST_PROXY_ACME_PROPAGATION_SECONDS` | DNS-01 propagation wait, 10..900 (default 60). |
|
||||
| `acme.renew_days` | `--acme-renew-days` | `RUST_PROXY_ACME_RENEW_DAYS` | Renew when this many days or fewer remain, 1..60 (default 30). |
|
||||
| `watch` | `--watch` | `RUST_PROXY_WATCH=1` | Reload automatically when the file or certificate files change ([below](#automatic-reload---watch)). |
|
||||
|
||||
Merging: lists (certificates, directories, ACME domains) from both places are joined; for single values (e-mail, provider, …) the command line wins; switches (`agree_tos`, `staging`, `auto`, `watch`) are on when either place turns them on. ACME settings are checked when the configuration is loaded, so they may be split between the two (for example the e-mail in the environment, the domains in the file). Changing the `"headless"` section takes effect with the next reload, except `watch`, which is read at start. `config validate` accepts the same command-line options and reports what was found.
|
||||
|
||||
Ready-made files: [`examples/headless-https-files.json`](../examples/headless-https-files.json) (certificate files and a Certbot directory), [`examples/headless-acme.json`](../examples/headless-acme.json) (ACME with `auto` and two vhosts), [`examples/headless-acme-wildcard-dns.json`](../examples/headless-acme-wildcard-dns.json) (wildcard through Cloudflare DNS-01) and [`examples/headless.environment`](../examples/headless.environment) (the same through `/etc/rustproxy/environment`).
|
||||
|
||||
### Existing certificate files
|
||||
|
||||
JSON:
|
||||
|
||||
```json
|
||||
"headless": { "tls": { "certificates": [ { "cert_file": "/etc/ssl/app/fullchain.pem", "key_file": "/etc/ssl/app/privkey.pem" } ] } }
|
||||
```
|
||||
|
||||
Command line:
|
||||
|
||||
```bash
|
||||
rust-proxy --headless --config /etc/rustproxy/config.json --data-dir /var/lib/rustproxy \
|
||||
serve --proxy-listen 0.0.0.0:80 --tls-listen 0.0.0.0:443 \
|
||||
--tls-cert-file /etc/ssl/app/fullchain.pem --tls-key-file /etc/ssl/app/privkey.pem
|
||||
```
|
||||
|
||||
Directories (`tls.directories` / `--tls-cert-dir`) recognize these layouts (other files are ignored):
|
||||
|
||||
| Layout | Example |
|
||||
|---|---|
|
||||
| The directory is one lineage | `DIR/fullchain.pem` + `DIR/privkey.pem` |
|
||||
| Certbot | `/etc/letsencrypt/live/<name>/fullchain.pem` + `privkey.pem` (symbolic links into `archive/` are followed) |
|
||||
| acme.sh | `DIR/<name>/fullchain.cer` + `DIR/<name>/<name>.key` |
|
||||
| Flat files | `DIR/<name>.crt` (or `.pem`, `.cer`) + `DIR/<name>.key` |
|
||||
|
||||
A directory is read again on each reload, so a Certbot deploy hook only has to run `systemctl reload rustproxy` (or nothing at all with `watch`). A new lineage added to the directory is picked up by the same reload. The files must be readable by the service account and pass the trusted-path checks described in [Certificates](CERTIFICATES.md) (for Certbot: give the `rustproxy` group read access to `live/` and `archive/`).
|
||||
|
||||
Each file certificate gets a stable id (`hl-file-<name>-<hash of the path>`); certificates issued by ACME get `hl-acme-<first name>-<hash of the names>`. The ids may be used elsewhere in the file, for example as `tls.default_certificate`, as long as the source that provides them stays configured.
|
||||
|
||||
### Automatic DV certificates (ACME)
|
||||
|
||||
JSON ([`examples/headless-acme.json`](../examples/headless-acme.json)):
|
||||
|
||||
```json
|
||||
"headless": {
|
||||
"acme": {
|
||||
"email": "ops@example.com",
|
||||
"agree_tos": true,
|
||||
"domains": [["app.example.com", "www.app.example.com"], ["api.example.com"]]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Command line:
|
||||
|
||||
```bash
|
||||
rust-proxy --headless --config /etc/rustproxy/config.json --data-dir /var/lib/rustproxy \
|
||||
serve --proxy-listen 0.0.0.0:80 --tls-listen 0.0.0.0:443 \
|
||||
--acme-domains app.example.com,www.app.example.com \
|
||||
--acme-domains api.example.com \
|
||||
--acme-email ops@example.com --acme-agree-tos
|
||||
```
|
||||
|
||||
or with the packaged service:
|
||||
|
||||
```bash
|
||||
cat <<'ENV' | sudo tee -a /etc/rustproxy/environment
|
||||
RUST_PROXY_ACME_DOMAINS=app.example.com,www.app.example.com;api.example.com
|
||||
RUST_PROXY_ACME_EMAIL=ops@example.com
|
||||
RUST_PROXY_ACME_AGREE_TOS=1
|
||||
ENV
|
||||
sudo systemctl restart rustproxy
|
||||
```
|
||||
|
||||
How it works:
|
||||
|
||||
- A few seconds after start RustProxy requests every certificate that is missing, was requested with different names, provider or environment, or expires within `renew_days`. It checks again every 12 hours and after every reload. Certificates are requested one at a time.
|
||||
- Issuance uses the same Certbot worker as the panel ([Certificates](CERTIFICATES.md)): a managed Python environment in `<data-dir>/acme-python` is prepared on the first request (Python 3 with `venv`/`pip` and access to PyPI, or a system `certbot` as a fallback). Account keys, Certbot lineages and logs are kept per certificate in `<data-dir>/certs/acme/`.
|
||||
- **HTTP-01** (default): the CA must reach `http://<name>/.well-known/acme-challenge/` on port 80 of this server, so RustProxy needs a plain HTTP listener on port 80 (directly or through port forwarding). Challenges are answered before vhost routing, also for vhosts with `force_ssl`, and only for names of the request in progress. Wildcards are not possible with HTTP-01.
|
||||
- **DNS-01** (`cloudflare`, `ovh`, `rfc2136`): needed for wildcards (`*.example.com`) and for servers not reachable from the Internet ([`examples/headless-acme-wildcard-dns.json`](../examples/headless-acme-wildcard-dns.json)). `dns_credentials` points to the INI file of the Certbot plugin, mode `0600`; it is read for each request, so rotated credentials need no restart:
|
||||
|
||||
```ini
|
||||
# cloudflare
|
||||
dns_cloudflare_api_token = <token with Zone:DNS:Edit>
|
||||
# ovh
|
||||
dns_ovh_endpoint = ovh-eu
|
||||
dns_ovh_application_key = ...
|
||||
dns_ovh_application_secret = ...
|
||||
dns_ovh_consumer_key = ...
|
||||
# rfc2136
|
||||
dns_rfc2136_server = 192.0.2.53
|
||||
dns_rfc2136_port = 53
|
||||
dns_rfc2136_name = keyname.
|
||||
dns_rfc2136_secret = <base64>
|
||||
dns_rfc2136_algorithm = HMAC-SHA256
|
||||
```
|
||||
|
||||
- A new certificate is written to `<data-dir>/certs/acme-*.pem|key`, recorded in `<data-dir>/certs/headless-acme.json` and activated by an internal reload: running connections and the cache are kept. The previous generation is deleted afterwards.
|
||||
- A failed request is logged with the path of the Certbot log and retried after 10 minutes, 30 minutes, 1, 3, 6 and then every 12 hours; Let's Encrypt limits failed validations, so test new setups with `staging` first. If the configuration file is invalid at that moment, the certificate is kept and applied by the next successful reload.
|
||||
- Removing a name from `domains` changes the certificate id; the old entry in `headless-acme.json` is simply no longer used.
|
||||
|
||||
### Automatic certificates for every vhost (`acme.auto`)
|
||||
|
||||
Like a Traefik certificate resolver attached to every router: with `"auto": true` (or `--acme-auto`) RustProxy collects the hosts of all enabled vhosts and redirects, leaves out those already covered by another certificate (from `tls.certificates`, certificate files/directories or `acme.domains`, wildcards included), and requests **one certificate per vhost** for the rest (up to 16 names each, at most 64 automatic certificates). Skipped automatically: `*`, IP addresses, single-label names and, with HTTP-01, wildcard hosts (they are requested with a DNS-01 provider).
|
||||
|
||||
Adding a vhost or a host and reloading (or saving with `watch`) is enough to get its certificate. When the hosts of a vhost change, a new certificate is requested first; the old automatic certificate is deleted only after its served names have a replacement, and certificates whose hosts are gone are deleted. `auto` needs `email` and `agree_tos` like any ACME request; `domains` may stay empty.
|
||||
|
||||
```json
|
||||
{
|
||||
"headless": { "watch": true, "acme": { "email": "ops@example.com", "agree_tos": true, "auto": true } },
|
||||
"vhosts": [
|
||||
{ "id": "app", "force_ssl": true, "frontend": { "hosts": ["app.example.com", "www.app.example.com"] },
|
||||
"backends": [ { "id": "a", "url": "http://127.0.0.1:3000", "allow_private": true } ] }
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
Only names that resolve to this server can pass HTTP-01; failures are retried with the back-off above and visible in [`/certificates`](#certificate-status-certificates).
|
||||
|
||||
### Quick start without a configuration file (`--route`)
|
||||
|
||||
Like Traefik's command-line routers, a vhost can be described in one option, `HOSTS=URLS`, with no `--config` at all:
|
||||
|
||||
```bash
|
||||
rust-proxy --headless --data-dir /var/lib/rustproxy serve \
|
||||
--proxy-listen 0.0.0.0:80 --tls-listen 0.0.0.0:443 \
|
||||
--route app.example.com,www.app.example.com=http://127.0.0.1:3000,http://127.0.0.1:3001 \
|
||||
--route api.example.com=http://127.0.0.1:8080 \
|
||||
--force-https --acme-auto --acme-email ops@example.com --acme-agree-tos
|
||||
```
|
||||
|
||||
- Each `--route` (environment `RUST_PROXY_ROUTES`, routes separated by `;`) becomes a vhost with WebSockets and `X-Forwarded-For`, balanced over the listed backends (up to 32) with the same defaults as a vhost in the file (default algorithm, TCP health checks every 5 s, so a backend takes traffic a few seconds after start once it passes them); retries, HTTP health checks and other balancing options are set in a file vhost. Private and loopback backends are allowed because the operator listed them. `*` as the host answers every name no other vhost claims.
|
||||
- `--force-https` (`RUST_PROXY_FORCE_HTTPS=1`) redirects plain HTTP to HTTPS (308) for these vhosts; ACME HTTP-01 challenges are still answered.
|
||||
- Routes can be combined with `--config`: they are added to the file's vhosts (a vhost id that already exists in the file is an error). Anything beyond this — cache, ACL, authentication, routes per path — belongs in the file.
|
||||
- `systemctl reload` / `SIGHUP` works without a file too; it re-reads certificate files and the ACME state.
|
||||
|
||||
### Automatic reload (`--watch`)
|
||||
|
||||
Like Traefik's file provider with `watch`: with `"watch": true` (or `--watch`, `RUST_PROXY_WATCH=1`) RustProxy checks every 2 seconds the configuration file, the configured certificate files and the contents of certificate directories (following Certbot's symbolic links). A change is applied once the files have stayed unchanged for one more check, so half-written files are not loaded. The reload is the same as `systemctl reload`: an invalid file is rejected and logged and the running configuration stays active. Write the file atomically (write a temporary file and rename it) when a tool generates it. Listener changes still need a restart.
|
||||
|
||||
### Certificate status (`/certificates`)
|
||||
|
||||
With `--health-listen`, `GET /certificates` returns every active certificate — id, source (`configuration`, `file`, `acme`, `acme-auto`), default flag, bound hosts, names from the certificate, issuer, `not_after`, `days_remaining`, `expiry_status` — and the state of each headless ACME request (`valid`, `issuing`, `waiting`, `failed` with the last error, failures and next check). It contains only public certificate data; keep the listener on loopback or a private network like `/healthz`.
|
||||
|
||||
```bash
|
||||
curl -s http://127.0.0.1:9091/certificates | jq '.certificates[] | {id, source, covered_hosts, days_remaining}'
|
||||
```
|
||||
|
||||
## Coming from Traefik or Envoy
|
||||
|
||||
| Traefik / Envoy | RustProxy headless |
|
||||
|---|---|
|
||||
| File provider, `watch: true` | `--config` JSON file, `"watch": true` / `--watch` |
|
||||
| CLI/labels routers (`Host(...)` → service) | `--route HOSTS=URLS`, or vhosts in the file; Docker labels through the [Docker agent](DOCKER_DISCOVERY.md) |
|
||||
| `certResolver` with HTTP or DNS challenge | `acme.domains`, `acme.auto`, `provider` `http01`/`cloudflare`/`ovh`/`rfc2136` |
|
||||
| Default certificate / TLS store | `tls.default_certificate`, `tls.certificates`, `headless.tls` |
|
||||
| Entry point redirect to HTTPS | vhost `force_ssl`, `--force-https` for `--route` |
|
||||
| Weighted round robin, backup servers | `load_balancing.algorithm`, backend `weight`, `backup`, `drain` |
|
||||
| Health checks / outlier detection | `health_check` (active), `passive_health` (ejection after real failures), `slow_start_seconds` |
|
||||
| Retry policy | `retry` (`max_retries`, connect errors, timeouts, statuses) |
|
||||
| Circuit breakers (`max_requests`, `max_pending_requests`) | backend `max_concurrent_requests` + `queue_timeout_ms`, vhost `rate_limit` |
|
||||
| Sticky sessions / hash policy | `sticky`, `ip_hash` |
|
||||
| Admin `/ready`, `/clusters`, `/certs` | `/healthz` (pools), `/certificates` on `--health-listen`; Prometheus `/metrics` |
|
||||
| Hot restart | `SIGHUP` reload without dropping connections; listener changes need a restart |
|
||||
|
||||
## Validate before starting
|
||||
|
||||
@@ -202,10 +418,11 @@ In a container, mount the file read-only (RustProxy never writes it) and keep `/
|
||||
"pools":[{"vhost":"app","healthy":3,"backends":3}]}
|
||||
```
|
||||
|
||||
`last_reload` reports the result of the last reload (`null` before the first one). Keep the listener on loopback or a private network.
|
||||
`last_reload` reports the result of the last reload (`null` before the first one). Keep the listener on loopback or a private network. The same listener serves [`/certificates`](#certificate-status-certificates).
|
||||
|
||||
## Limits
|
||||
|
||||
- No panel, live logs (`--livelogs`), configuration history browser or cache invalidation API. Use stored log files, the journal and Prometheus instead; HTTP `PURGE`/`BAN` from allowed addresses still works for the cache.
|
||||
- Certificates with ACME auto-renewal are refused; renew externally and reference the files in `cert_file` / `key_file`. A replaced certificate file is loaded on the next reload.
|
||||
- Certificates in the file with ACME auto-renewal (`issuer.auto_renew`) are refused; use `--acme-domains` instead, or renew externally and reference the files in `cert_file` / `key_file`. A replaced certificate file is loaded on the next reload.
|
||||
- Certificates from `headless.tls`, `headless.acme`, `--tls-cert-file`, `--tls-cert-dir` or `--acme-*` and vhosts from `--route` exist only in headless mode; remove the `"headless"` section before using the file in the panel and, before switching to the panel, import them there (or reference the files in `tls.certificates`).
|
||||
- To manage a headless file in the panel later, first add `listeners` and every `listener_ids` explicitly (panel mode requires them and enables GeoIP downloads by default), then restart without `RUST_PROXY_HEADLESS`, create the administrator and keep `--config`: panel saves then write the complete configuration to the file.
|
||||
Reference in new issue
Block a user