v0.41.0
This commit is contained in:
1 parent
54b2ac0838
commit
3b953dcdc6
23 files changed
+643
-29
No files matched your search
@@ -59,7 +59,7 @@ Example — beta testers by header, office network with a staff cookie for the w
|
||||
|
||||
### Routing tester
|
||||
|
||||
**Vhosts → Edit → Custom locations → Test routing** evaluates the unsaved draft in the browser: enter a method, URL, client IP, country and headers (cookies as a `Cookie:` header) to see which location wins, why every other location was skipped (path ✓/✗ and each condition ✓/✗), the backend or hash target and whether the cache is bypassed. Its matching logic is checked against the proxy with the shared cases in `tests/fixtures/routing_conditions_cases.json` (`tools/dev/test_routing_tester.js`). Regular expressions are run by the browser engine, which covers the common syntax; the server always validates the saved configuration.
|
||||
**Vhosts → Edit → Custom locations → Test routing** evaluates the unsaved draft in the browser: enter a method, URL, client IP, country and headers (cookies as a `Cookie:` header) to see which location wins, why every other location was skipped (path ✓/✗ and each condition ✓/✗), the backend or hash target and whether the cache is bypassed. Its matching logic is checked against the proxy with the shared cases in `tests/fixtures/routing_conditions_cases.json`. Regular expressions are run by the browser engine, which covers the common syntax; the server always validates the saved configuration.
|
||||
|
||||
## Actions
|
||||
|
||||
@@ -76,7 +76,7 @@ Example — beta testers by header, office network with a staff cookie for the w
|
||||
|
||||
## Headers, access and method rules
|
||||
|
||||
Each location can add request/response header operations (`set`, `append`, `remove`), reusable ACL profiles, inline IP/CIDR rules, country access and HTTP-method allow/block lists. Every applicable host and Vhost policy must still pass; a location cannot remove a higher-level denial. Transport/forwarded-identity headers are protected from unsafe overrides. Authentication, rate limits, WebSocket policy and other Vhost settings continue to apply.
|
||||
Each location can add request/response header operations (`set`, `append`, `remove`; values may use variables such as `%[srv_id]` — see [Variables in header values](RESPONSE_DELIVERY.md#variables-in-header-values-diagnostic-headers)), reusable ACL profiles, inline IP/CIDR rules, country access and HTTP-method allow/block lists. Every applicable host and Vhost policy must still pass; a location cannot remove a higher-level denial. Transport/forwarded-identity headers are protected from unsafe overrides. Authentication, rate limits, WebSocket policy and other Vhost settings continue to apply.
|
||||
|
||||
## Internal error fallback
|
||||
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@ RustProxy is a single service that combines a reverse proxy, a static/PHP web se
|
||||
|---|---|
|
||||
| Vhosts | Exact and wildcard hostnames, aliases, several listeners per Vhost, per-Vhost HTTP/2 and HTTP/3 switches |
|
||||
| Backends | HTTP and HTTPS origins, HTTP/1.1, automatic ALPN (H2/H1), strict HTTP/2 and H2C, optional upstream certificate verification with custom CA and server name |
|
||||
| Load balancing | Least connections (default), round robin, least traffic, adaptive, random (two choices), consistent hash of path / URI / host / header / cookie / query parameter / client IP with optional bounded load, and IP hash; member weights, backup and draining members, sticky cookie or IP affinity; per-location backend groups with their own algorithm (HAProxy `use_backend` style); in-panel distribution simulator. Conditional routing: locations and whole-host rules selected by header, cookie, query parameter, method, client IP/CIDR, host or country (AND of conditions, negation, regex), with an in-panel routing tester. See [Load balancing](LOAD_BALANCING.md) |
|
||||
| Load balancing | Least connections (default), round robin, least traffic, adaptive, random (two choices), consistent hash of path / URI / host / header / cookie / query parameter / client IP with optional bounded load, and IP hash; member weights, backup and draining members, sticky cookie or IP affinity; per-location backend groups with their own algorithm (HAProxy `use_backend` style); in-panel distribution simulator. Conditional routing: locations and whole-host rules selected by header, cookie, query parameter, method, client IP/CIDR, host or country (AND of conditions, negation, regex), with an in-panel routing tester. Header rules accept HAProxy-style variables (`%[srv_id]`, `%[location]`, `%[hash_key]`, `%[cache_status]`, …) with one-click diagnostic header presets. See [Load balancing](LOAD_BALANCING.md) |
|
||||
| Health checks | Active TCP or HTTP probes with thresholds, optional separate probe port, expected response text and live health status per member |
|
||||
| Connection reuse | Bounded keep-alive pools with idle and age limits, pool recycling and protocol telemetry |
|
||||
| Custom locations | Prefix, exact and regex paths, path rewriting, per-location backends, Web Services, local responses, redirects and internal error fallbacks |
|
||||
|
||||
@@ -121,11 +121,13 @@ In the panel: add the three backends with **Include in the default load-balancin
|
||||
|
||||
Locations can additionally require request conditions (header, cookie, query parameter, method, client IP, host, country), and a match type `any` turns a location into a rule for the whole host — together the full HAProxy `use_backend <group> if <acls>` pattern. See [Custom locations → Request conditions](CUSTOM_LOCATIONS.md#request-conditions-routing-by-header-cookie-ip).
|
||||
|
||||
To see which shard served a request, add a response header rule such as `X-S: %[srv_id]` or `X-LB: %[lb_algorithm] %[hash_key]` (one click under **Backends → Backend diagnostics**); see [Variables in header values](RESPONSE_DELIVERY.md#variables-in-header-values-diagnostic-headers).
|
||||
|
||||
## Panel helpers
|
||||
|
||||
- **Quick setup** buttons fill typical combinations: files by path, session cookie, tenant header, query parameter, client IP, or even load spreading.
|
||||
- Each algorithm shows a short explanation, and hash settings show the **HAProxy equivalent** lines for comparison.
|
||||
- **Test distribution** runs in the browser on the unsaved draft. Paste sample paths, URLs or key values to see the hash key and the selected backend for each, the share per backend, and — after ticking **Simulate failure of** — which keys would move. The simulator uses the same SHA-256 rendezvous scoring as the proxy (checked by `tools/dev/test_balance_simulator.js`); load-based algorithms show the expected share by weight instead. It does not account for current concurrency limits, bounded-load spill-over or live health.
|
||||
- **Test distribution** runs in the browser on the unsaved draft. Paste sample paths, URLs or key values to see the hash key and the selected backend for each, the share per backend, and — after ticking **Simulate failure of** — which keys would move. The simulator uses the same SHA-256 rendezvous scoring as the proxy (reference vectors in `tests/fixtures/balance_rendezvous_vectors.txt`); load-based algorithms show the expected share by weight instead. It does not account for current concurrency limits, bounded-load spill-over or live health.
|
||||
|
||||
## Compatibility and limits
|
||||
|
||||
|
||||
@@ -37,6 +37,44 @@ Transformations can run on eligible reverse-proxy and Web Server responses. When
|
||||
|
||||
Configure global response headers, Vhost-specific policies and Web Server/location headers at the appropriate scope. Header rules can set, append or remove allowed names. Certain routing, forwarding, framing, cache diagnostics and security-sensitive fields are protected or subject to extra validation. Review especially HSTS, CSP, CORS and application-specific cookies before using a broad rule.
|
||||
|
||||
### Variables in header values (diagnostic headers)
|
||||
|
||||
Since 0.41.0 a `set`/`append` value can contain variables written as `%[name]`, like HAProxy sample fetches (`http-response set-header X-S %[srv_id]`). They work in global, Vhost and location rules, for both directions:
|
||||
|
||||
| Variable | Value |
|
||||
|---|---|
|
||||
| `%[srv_id]` | ID of the backend that served the request (e.g. `mp3_2`); `-` on a cache hit, when no backend was contacted |
|
||||
| `%[srv_url]` | URL of that backend |
|
||||
| `%[location]` | custom location ID, or `main` for the Vhost source |
|
||||
| `%[vhost]` | Vhost ID |
|
||||
| `%[lb_algorithm]` | balancing algorithm used (`hash`, `least_connections`, …) |
|
||||
| `%[hash_key]` | key of consistent hashing (path, header value, client IP…) |
|
||||
| `%[client_ip]` | client address as determined by RustProxy |
|
||||
| `%[country]` | client country when GeoIP or Cloudflare provides it |
|
||||
| `%[req_id]` | request ID |
|
||||
| `%[method]`, `%[host]`, `%[path]` | request method, host name and routing path |
|
||||
| `%[cache_status]` | `HIT`, `MISS` or `BYPASS` — response rules only |
|
||||
| `%[backend_time]` | backend response time, e.g. `12.40ms` — response rules only |
|
||||
|
||||
Example — show the shard in the response and tell the backend which shard it is:
|
||||
|
||||
```json
|
||||
"headers": {
|
||||
"request": [{ "op": "set", "name": "X-Shard", "value": "%[srv_id]" }],
|
||||
"response": [{ "op": "set", "name": "X-S", "value": "%[srv_id]" },
|
||||
{ "op": "set", "name": "X-Debug", "value": "%[location] -> %[srv_id] (%[cache_status], %[hash_key])" }]
|
||||
}
|
||||
```
|
||||
|
||||
Rules:
|
||||
|
||||
- Rules with variables are evaluated **per request and applied last** in their direction: request rules after the backend is selected (on a failover retry the request keeps the first backend's value; the response shows the final backend), response rules at final delivery after cache handling. They are **never stored in the cache**, so a cached object never carries another client's values. Static rules behave as before.
|
||||
- A variable without a value for the request renders as `-`. If the rendered value is not a valid header value the header is skipped (CR/LF can never be injected).
|
||||
- Unknown variables, an unterminated `%[` and `%[cache_status]` / `%[backend_time]` in request rules are rejected when saving. Protected header names stay protected.
|
||||
- Values such as `%[path]`, `%[host]` and `%[hash_key]` echo client input, and `%[srv_id]` / `%[srv_url]` reveal internal names — use diagnostic headers for testing or restrict them to trusted locations.
|
||||
|
||||
In the panel the header-rule editors show clickable variable chips, and **Vhost → Backends → Backend diagnostics** has one-click presets (`X-Served-By`, `X-Location`, `X-LB`, `X-Debug`, `X-Shard` to the backend) that add the corresponding rules to the Vhost's header rules. The existing switch *Expose selected backend* (`X-Rust-Proxy-Backend`) is unchanged.
|
||||
|
||||
For controlled rollout:
|
||||
|
||||
1. Enable only the codec/types required, then test with and without `Accept-Encoding` and with ordinary browsers.
|
||||
|
||||
Reference in new issue
Block a user