Repository navigation
Releases
1.0.0-beta.2
Upgrade notes
Upgrade the gateway, tailer and reaper together. The journal gains fields: whether a body was capped, and whether r7 relayed the upstream's head. A beta.1 tailer reading a beta.2 journal fails silently: it writes a capped body to WARC as if it were whole, and writes r7's own 502 as if the upstream had sent it. The tailer also changes how it stores bodies and frees native memory it used to leak (below), so a beta.1 tailer must not be kept.
Licence: r7 is Apache 2.0 from this release. The BSL no longer applies to any module (#283).
Check your config before you deploy: docker run --rm --env-file .env -v "$PWD/routes.yaml:/app/config/routes.yaml:ro" ghcr.io/ethlo/r7-gateway:1.0.0-beta.2 --validate-only. beta.1 files need these changes:
| beta.1 | beta.2 |
|---|---|
global_filters: |
filters: at the root of routes.yaml. It is one instance for everything beneath it, as group and route filters are. |
journal.request.status_overrides / journal.response.status_overrides |
An on_response rule: - match: [{ Status: { include: [401, 403, 5xx] } }] then request: { level: HEADERS } (see docker/config/routes.yaml and docs/journaling.md). |
$${name} for a named group in RewritePath and TemplateRedirect |
{name}, with \{ for a literal brace. The old form is refused with a message saying so. |
TemplateRedirect status set to any code |
301, 302, 303, 307 or 308 only. |
Host hosts: ["a,b"] matched the literal a,b |
A comma now separates hosts, so hosts: ["${HOST_LIST}"] works. |
CircuitBreaker in the root's or a group's filters |
Declare it on each route it protects; above route level it is refused. |
StaticContent base_directory: /var/www |
directories: [/var/www]. Several directories are checked in order, the first that has the file answering (#261). |
leg on a request predicate (Path, RequestHeader, RemoteAddr, ...) |
Drop it. Request predicates always test the request as the client sent it; only response predicates (Status, HasResponseHeader, MatchResponseHeader) take leg. |
Several RewritePaths on a route, one of them setting the query |
Refused. A query-setting rewrite must be the only RewritePath the route runs, counting the root's and the group's (#255). |
RequireAuthorizationHeader |
Removed: it checked only the Bearer /Basic prefix and authenticated nothing. Use BasicAuth, or RequireMatchRequestHeader with name: Authorization for a prefix check. |
RemoveCacheHeaders |
Removed. RemoveRequestHeader for If-Modified-Since and If-None-Match, SetRequestHeader for Cache-Control and Pragma. |
StaticContent list_directory |
Removed: a directory without a welcome file is answered 403. |
json.bodies: true / json.bodies: false in tailer.yaml |
inline / none, or files for body files. The boolean is refused with what replaced it (#287). |
JwtAuth issuer and jwks_url, one issuer |
Unchanged. For several issuers use issuers: instead; the two forms cannot be mixed (#285). |
BasicAuth's gateway.auth.basic.user attribute, a fingerprint of the username |
The JSON line's identity object, in plain text: {"scheme": "basic", "subject": "alice", "username": "alice"} (#264). |
The old keys are reported as plain unknown options.
Security
- A rewritten path is checked before it is forwarded (#254). A
RewritePathwith{query.NAME}in the path could forward a..segment that r7 refuses from clients:/files/{query.name}with?name=..%2Fadminreached the upstream as/files/../admin. Every path a filter changes now gets the same ambiguity check, and fails with400. - Plugin code runs with the gateway's rights. The docs now say to keep the plugins directory read-only to the gateway.
Configuration
JwtAuthverifies aBearerJWT against a JWKS endpoint.issuerandaudienceare required, only RS, PS and ES signatures are accepted, a JWKS outage is answered with503, andforward_claims_as_headerspasses claims to the upstream (#264). Client spellings of the forwarded headers (X_User_Nameand the like) are removed before the verified value is set.JwtAuthtakes several issuers withissuers:, such as one Keycloak with a realm per tenant (#285). A token'sissis matched exactly against the list before any key is fetched, so an unknown issuer gets401with no network call. Each issuer has its own JWKS URL (default: the issuer plus/protocol/openid-connect/certs) and its own key cache; one issuer's outage answers503only for its own tokens.forward_claims_as_headerscan forwardiss, so upstreams key on issuer and subject.- Root, group and route levels in
routes.yaml(#238). A group'smatchis tested once before its routes. Filters at a level are one instance for everything beneath it. Upstream keys are inherited key by key. Routes that take all their upstream keys from one declaration share one connection pool and health state (#240). --validate-onlychecks the config the way a start would, without starting the gateway (#230).upstream.preserve_hostforwards the client'sHost(#234).- RewritePath can set the query with
{query.NAME}and captures (#236). TemplateRedirect can take query values, andsourceis optional (#232). - Response predicates
Status,HasResponseHeaderandMatchResponseHeader, withleg: client|upstreamto test the response the client got or the one the upstream sent, andSamplefor canaries (#241, #242). Request predicates test the request as the client sent it and take noleg(#260). - CircuitBreaker judges upstream outcomes when the exchange completes, and adds
slow_call(#231). ACircuitBreakerbelongs on a route: at the root or on a group it is refused (#256, #258). - Filter factories declare where they apply (#258). A filter factory's
levels()names the levels it may be declared on, defaulting to all, so existing plugins load unchanged. - StaticContent serves from several
directories, the first that has the file answering (#261), and takes afallbackfile such asindex.htmlfor single-page apps (#263). A file or folder the gateway may not read answers403with one warning per directory naming the path; it no longer looks absent, and lower directories are not tried in its place (#273). - Plugins: jars in
plugins/(orR7_PLUGINS_DIR,/app/pluginsin the image), with one class loader per plugin directory (#226, #245).
Journal
- Journal rules:
on_requestandon_responseat the root, on a group or on a route replacestatus_overrides. The first matching rule per stage wins, and its id is journaled asgateway.journal.rule(#244). truncate_body_atcaps the journaled body per direction. Traffic still streams whole. WARC marks capped recordsWARC-Truncated: length, and the JSON line marks thembody_truncated: true(#246).- Silent routes write nothing, and the management view shows
rule_errors(#247). Unroutedon_requestrules take theUnroutedReasonpredicate (#248). - The caller's identity is journaled in plain text: the JSON line's
identityholds the scheme, issuer, subject and username thatBasicAuthorJwtAuthverified. Plugins set it throughIdentityin r7-api, and read claims throughClaims(#264). - No made-up upstream response. When no upstream answered, the journal records no upstream response instead of r7's own 502/503/504 (#229).
- The response is finalised in one place at commit, for short circuits and static content too (#243).
- The upstream request is journaled as it was sent (#265). The
upstream_requestleg holds the request line and headers the relay wrote, including the rewrittenHost,X-Forwarded-*and the target's path. Status lines come from a table covering every registered code, so a101or307no longer reads "Unknown". - Standard protocol headers are journaled in plain text (#266): conditional and content headers, CORS preflight names, WebSocket version and extensions, and response caching and policy headers. Anything that can carry a credential stays fingerprinted (
Referer,Sec-WebSocket-Protocol,Content-Security-Policy,Location).
Tailer
- Body files (#287).
json.bodiesisnone,inlineorfiles. Withfiles, each body the WARC output does not store is compressed as one Zstandard frame into rotating.bodies.zstfiles, and each client leg of the JSON line gets abody_refwith file, offset and length. A body is stored once per file by SHA-256. Bodies are appended before the line and taken back if the line fails.filesis refused beside a WARC output that stores bodies. The tailer image prepares/bodies. There is no retention or deletion of body files. - WARC on standard output (#288). When a line may have reached standard output despite a reported failure, the tailer keeps its WARC records, per exchange across interleaved retries, so the retry never duplicates or loses an exchange.
- Native memory leak fixed (#289). The tailer leaked one zstd decompression context per decode, so native memory grew until the container was OOM-killed while the JVM heap stayed flat. The context now lives for the tailer's life and is closed on shutdown. Anonymous RSS stays flat over 30,000 write-and-tick cycles. Every tailer running beta.1 under load is affected.
- Loading into ClickHouse (#291). The
where-r7-fitssnippet ships the JSON lines to ClickHouse unparsed and lets ClickHouse parse them, which takes far less Vector CPU.migrations/has a materialized view that loads the lines into an existing gateway log table in the shape it already uses.
Fixes
1.0.0-beta.1
The first beta of r7, the gateway that remembers every request.
r7 routes traffic to your services and records every exchange on local disk, with no network call while the client waits. One routes.yaml, strictly validated before it serves a single request.
What's in it
- Every exchange on record. Metadata, headers or full bodies, chosen per route and per direction. Secrets are stored as keyed fingerprints, never in the clear.
- Sidecars for the journal. The tailer turns the journal into WARC files (with an optional CDXJ index) and JSON lines; the reaper deletes segments once the tailers are done with them.
- Performance you can measure. 2.3–2.9× the throughput of Spring Cloud Gateway on the same cores, reproducible with one command. See the [benchmarks](https://r7.ethlo.com/benchmarks/).
- Extensions in plain Java. Each stage of a request has its own interface, alongside 33 built-in filters and 15 predicates.
- Configuration you can trust. A full schema with precise errors, and hot reload that rejects a bad edit while your routes keep running.
- Operable from day one. A dashboard, Prometheus
/metrics,/healthand/readyon the management port.
Images
ghcr.io/ethlo/r7-gateway:1.0.0-beta.1
ghcr.io/ethlo/r7-tailer:1.0.0-beta.1
ghcr.io/ethlo/r7-reaper:1.0.0-beta.1
Pre-releases never get latest or other floating tags. Pin the exact version.
Getting started
The [quickstart](https://r7.ethlo.com/quickstart/) has you running in five minutes.
Before 1.0
This is a beta. The configuration and the journal format can still change between betas; each change will be called out in the release notes. Feedback and issues are very welcome.