This commit is contained in:
Mateusz Gruszczyński committed 2026-11-26 08:50:30 +01:00
1 parent 167861fc16
commit aa0a271a1c
38 files changed
+3642 -1058

No files matched your search

+2 -2
View File
@@ -8,7 +8,7 @@ RustProxy is a single service that combines a reverse proxy, a static/PHP web se
| Feature | Details |
|---|---|
| Vhosts | Exact and wildcard hostnames, aliases, several listeners per Vhost, per-Vhost HTTP/2 and HTTP/3 switches |
| Vhosts | Exact and wildcard hostnames, aliases, several listeners per Vhost, per-Vhost HTTP/2 and HTTP/3 switches; visual editors with scoped JSON drawers for locations, inline IP ACLs and headers |
| 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. 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 |
@@ -16,7 +16,7 @@ RustProxy is a single service that combines a reverse proxy, a static/PHP web se
| Custom locations | Prefix, exact and regex paths, path rewriting, per-location backends, Web Services, local responses, redirects and internal error fallbacks |
| WebSockets | HTTP/1.1 Upgrade, RFC 8441 (HTTP/2) and RFC 9220 (HTTP/3) Extended CONNECT |
| Forwarding headers | `X-Forwarded-*`, `Forwarded`, `X-Real-IP`, trusted proxy ranges, Cloudflare client IP and country |
| HTTP policies | Optional global, Vhost, Docker-assignment and location policies: named ACLs, nested AND/OR/NOT, typed samples, maps, transaction variables, header/list operations and explicit request/response stages. Strict HAProxy subset importer, draft tester and [VCL cooperation](POLICY.md) with legacy precedence preserved. |
| HTTP policies | Optional global, Vhost, Docker-assignment and location policies: named ACLs, nested AND/OR/NOT, typed samples, maps, transaction variables, header/list operations and explicit request/response stages. Shared editor with 40 searchable scenarios built from 54 rules (39 scenarios at location scope), condition builder, JSON view, strict HAProxy subset importer and draft tester. Application/CORS/cache/security/routing presets show their defaults; recipes requiring setup are added disabled. [VCL cooperation](POLICY.md) preserves legacy precedence. |
| Redirects and pages | Redirect hosts, canonical host and HTTPS redirects, 404 hosts, custom error pages and direct-IP pages |
| TCP/UDP Streams | Layer-4 forwarding with backend pools, health checks, session limits and idle timeouts |
+5 -5
View File
@@ -5,10 +5,10 @@ Use maintained packages whenever possible. For custom installations, use the scr
## Supported entry points
| Installation | Recommended starting point |
|---|---|
| Linux DEB/RPM (RustProxy server) | https://rustproxy.linuxiarz.pl/ |
| Docker host discovery agent (independent DEB/RPM) | `sudo apt install rustproxy-docker-agent` or `sudo dnf install rustproxy-docker-agent`; see [Docker discovery](DOCKER_DISCOVERY.md) |
| OPNsense plugin | https://rustproxy-opn.linuxiarz.pl/ |
| --- | --- |
| Linux DEB/RPM (RustProxy server) | <https://re.linuxiarz.pl/> |
| Docker host discovery agent (independent DEB/RPM)po | `sudo apt install rustproxy-docker-agent` or `sudo dnf install rustproxy-docker-agent`; see [Docker discovery](DOCKER_DISCOVERY.md) |
| OPNsense plugin | <https://rustproxy-opn.linuxiarz.pl/> |
| Debian 13+ source bootstrap | `install-debian13.sh` from the project repository |
| Manual Linux/systemd install | Compile the application; use `install.sh` and `update.sh` |
| OCI container | Included `Dockerfile`; see [Docker / OCI container](#docker--oci-container) |
@@ -56,7 +56,7 @@ Use `--plan` to inspect changes first. The installer refuses existing unmanaged/
For the standard managed Linux installation:
| Item | Default |
|---|---|
| --- | --- |
| HTTP frontend | `0.0.0.0:80` |
| HTTPS frontend | `0.0.0.0:443` with an initially self-signed certificate |
| Administration | `127.0.0.1:9090`, HTTP on loopback |
+119 -2
View File
@@ -18,8 +18,9 @@ below. VCL remains the owner of its existing cache-rule precedence and terminal
- In the panel, open **Settings → Rules & headers → HTTP policies** globally,
**Vhost → Headers → HTTP policies**, the location's **HTTP policies** section,
or the Docker assignment's policy section. The shared editor offers a rule
builder, a JSON view, import preview and a draft tester. Reordering uses the
visible rule order; switching views preserves the same policy object.
builder, scenario presets, a JSON view, import preview and a draft tester.
Global settings use the same editor at `settings?tab=policies`. Reordering uses
the visible rule order; switching views preserves the same policy object.
- Set `policy` in the complete configuration, `vhosts[].policy`, or
`vhosts[].routes[].policy`. A Docker assignment stores its policy with that
assignment so discovery does not discard the customization.
@@ -39,6 +40,122 @@ headless test after adjusting its backend address. The
[cooperation example](../examples/policy-vcl-cooperation.json) demonstrates a
request classification consumed by VCL-style cache rules.
## Scenario presets and the rule builder
Since 0.42.1, **Scenario presets** beside **Add HTTP rule** opens a searchable catalog
grouped by headers, cache, security, routing and diagnostics. Select a scenario
to read its purpose and application notes; **Preview rules** shows its policy
data. **Add scenario** appends the complete scenario to the current draft with
unique rule IDs. It keeps the existing rules, ACLs and maps. Nothing is activated
until the containing Settings, Vhost, Docker assignment or location form is
saved. The **Documentation** button in the editor toolbar opens this guide;
Vhosts and global settings use the same control.
The catalog contains **40 scenarios built from 54 rules**. Global and Vhost
editors offer all 40. Location editors offer 39: the prefix rewrite uses
`pre_route`, which runs before a location has been selected.
### General scenarios
The following recipes create enabled draft rules, except the disabled legacy
redirect. They still require saving the containing form to become active.
| Scenario | Effect and review points |
| --- | --- |
| Normalize `Vary` | Normalize the final token list, keeping existing dimensions and `*`. |
| Exact duplicate `Vary` | Match the two full fields in the [original example](#exact-duplicate-vary-rule) and replace only that exact combination before cache planning. |
| Hide origin headers | Remove `Server`, `X-Powered-By` and `X-AspNet-Version` from the final response. |
| Basic security headers | Add `X-Content-Type-Options: nosniff` and `Referrer-Policy: strict-origin-when-cross-origin` only when missing; application-provided values remain in place. |
| Private routes | Bypass shared lookup/storage and send private/no-store response headers on common account, administration and checkout paths. Adjust the path list. |
| Authorization bypass | Bypass shared caching when an `Authorization` header is present and send private/no-store response headers. |
| Cookie bypass | Bypass shared caching when a `Cookie` header is present and send private/no-store response headers. This also excludes anonymous requests with tracking cookies. |
| Responses with `Set-Cookie` | Prevent storage of matching origin responses without deleting the cookie; send `Cache-Control: private, no-store`. |
| Error responses | Prevent storage of origin responses with status `400`–`599`; send `Cache-Control: no-store` on final error responses. |
| Health endpoints | Keep common health/readiness paths out of shared caching and mark their responses no-store. Adjust the paths to match your service. |
| Server-sent events | Bypass shared cache for `Accept: text/event-stream`; prevent storage and disable RustProxy compression for event-stream responses. This does not remove origin compression. |
| Block unwanted methods | Return `403` for `TRACE` and `CONNECT`; review them against protocols used by the service. |
| Block sensitive files | Return `403` for literal `.env`, `.env.*`, `.git`, `.svn` and `.hg` path segments. The pattern leaves `.well-known` available and does not cover all encoded aliases. |
| Request correlation | Add the transaction request ID as `X-Correlation-ID` at final delivery when absent; preserve application correlation IDs. |
| Legacy path redirect | Add a disabled exact `/old-path` → `/new-path` redirect with status `302`. Edit the paths and enable the rule; this example drops the original query string. |
### Application and API scenarios
**Off** means the scenario is added with every rule disabled. Edit its example
domains, paths, networks or values, enable the required rules, then save. Keep
the order of a scenario containing several rules.
| Scenario | Added state | Effect and review points |
| --- | --- | --- |
| Language variants | Off | Merge `Accept-Language` into `Vary` before cache planning for `/localized/`; use only when the origin actually varies its response by that header. |
| CORS for one frontend | Off | On `/api/`, remove previous allowed-origin/credentials headers, allow the fixed `https://app.example.test` origin, and merge `Origin` into `Vary` for all matching responses. |
| CORS exposed headers | On | Merge `ETag` and `X-Correlation-ID` into `Access-Control-Expose-Headers` only when an allowed-origin response header already exists. Does not grant CORS access or create those diagnostic headers. |
| Internal redirect locations | Off | Replace the configured internal HTTP host in `3xx` `Location` fields with a fixed public HTTPS host, preserving the captured path/query. Does not rewrite page content. |
| Download attachments | Off | Set `Content-Disposition: attachment` on successful responses under `/downloads/`; edit the path. No filename or access permission is generated. |
| Same-origin framing | Off | Add `X-Frame-Options: SAMEORIGIN` when missing. Review embedded applications and any existing CSP `frame-ancestors` directive. |
| Trial HSTS | Off | Add missing `Strict-Transport-Security: max-age=300` only on the actual TLS listener; no `includeSubDomains` or `preload`. Verify HTTPS first. |
| Browser device permissions | Off | Add missing `Permissions-Policy` denying camera, microphone and geolocation; remove restrictions required by the application. |
| CSP report-only audit | Off | Add a missing report-only CSP for self-hosted resources, no objects and a self-only base URI. Review browser-console violations; no report endpoint is configured. |
| Staging noindex | Off | Send `X-Robots-Tag: noindex, nofollow` throughout the selected scope. This is crawler advice, not authentication. |
| Cross-site write requests | Off | Deny `POST`, `PUT`, `PATCH` and `DELETE` carrying `Sec-Fetch-Site: cross-site`. Keep application CSRF protection; clients without that header are unaffected. |
| JSON API writes | Off | Require exactly one `Content-Type` field declaring `application/json` or `application/*+json` for `POST`, `PUT` and `PATCH` below `/api/`, otherwise return `415`. Missing or duplicate fields are rejected. This checks headers, not body validity. |
| Internal path by client network | Off | Deny `/internal` outside the configured trusted client-IP CIDR. Replace the example `203.0.113.0/24` and path before enabling. |
| Preview/draft query parameters | Off | Bypass lookup/storage and send private/no-store when literal `preview` or `draft` query names exist, even with empty or false values. Does not authorize draft access. |
| Signed/token URLs | Off | Bypass lookup/storage for configured literal signing/token query names. The application still validates the signature and expiry. |
| HTML revalidation | On | Add `Cache-Control: no-cache` only to HTML responses lacking `Cache-Control`. Existing privacy directives remain; the shared object's TTL is unchanged. |
| Public API TTL/grace | Off | Set 60-second TTL and 30-second grace defaults for explicitly public `/api/public` responses without `Set-Cookie`, `private`, `no-cache` or `no-store`. Requires enabled cache. |
| Canonical host | Off | Redirect a configured alias to a fixed HTTPS hostname with `308`, preserving path, query and method. Edit both domains and verify the certificate. |
| HTTP to HTTPS for one host | Off | Redirect the configured host with `308` when received without TLS. Uses listener TLS, not forwarding headers; review external TLS termination to avoid loops. |
| Remove a path prefix | Off | Rewrite `/legacy/…` to `/…` in `pre_route`, retaining query parameters. Review routing/access for the resulting path; available globally and on Vhosts only. |
| Move a URL subtree | Off | Redirect `/docs-old/…` to `/docs/…` with `308`, preserving the rest of the path, query and method. Edit the condition and replacement together. |
| Maintenance response | Off | Return a local `503` after access/authentication checks and add `Retry-After: 300` using a transaction marker. Enable both rules together; the initial condition covers the whole scope. |
| Selected API backend | Off | Send `/api-v2/` to an existing backend member ID. Set the real ID before enabling; backend selection bypasses shared cache. Global use requires that member in each affected Vhost. |
| Cache outcome header | On | Add missing `X-Cache` from `cache_status` at final delivery. Preserves an application header and does not change cache decisions. |
| API/web classification | Off | Set `txn.ui_request_class` to `web` or `api`, then expose it as `X-Request-Class` at delivery. Edit `/api/` and retain all three rules in order; the label is not a trusted identity. |
The CORS recipe configures **response headers only**. The application must handle
`OPTIONS` preflight and authentication. The recipe does not allow credentialed
browser requests or reflect an arbitrary request origin. Enable both rules
together so every applicable response retains `Vary: Origin`.
The public-API TTL/grace recipe does not force cache lookup or weaken credential
and storage privacy checks. Existing VCL TTL/grace assignments take precedence.
Its backend-response stage retains the background-refresh restrictions below.
`no-cache` in the HTML recipe means revalidation, not a prohibition on storage.
Presets are editable starting points; they do not install authentication or
replace existing access rules.
For global policies, review the effects across every affected Vhost. Response
storage rules do not purge existing cache entries or run the backend-response
stage on a HIT. Backend-response rules also retain the background-refresh
restrictions described under [cache boundaries](#actions-and-cache-boundaries).
For the event-stream preset, clients must send `Accept: text/event-stream` to
bypass any existing cache entry before the origin's response type is known.
### Add and inspect conditions
Open a rule's conditions, enter a sample expression, choose an operator and
enter one comparison value per line. **Add condition** commits those fields to
the rule and updates its visible condition list/count. The initial sample is
`path` with a prefix comparison; enter the intended path before adding it.
Choose **AND** to require both the existing condition and the new comparison,
or **OR** to allow either. Existing nested expressions remain grouped.
The builder checks for missing samples/values, invalid numeric values and
condition/value limits before adding a comparison. **exists** takes no values;
case-insensitive matching applies to text comparisons, not numeric, CIDR or
existence tests. **Advanced condition JSON** remains available for nested
AND/OR/NOT expressions and named ACL references. Invalid JSON must be corrected
before switching views or applying changes that would rebuild the editor.
The server still validates sample syntax, stage compatibility and the complete
policy before activation.
Action choices follow the selected stage. **Stop this scope's stage after
matching** has its own row below the stage settings; it ends only the matching
scope's chain at that stage. Policy on/off controls follow **Show on/off settings
as switches** in Appearance, including dynamically added rules and conditions.
The same behavior applies in global settings, Vhosts, Docker assignments and
locations.
## Stages and existing rules
| Stage | Runs when | Relationship to VCL and existing headers |
+2 -2
View File
@@ -16,13 +16,13 @@ Guides for operating RustProxy: installation, publishing services, security, cer
- [Installation and updates](INSTALL.md) — packages, source build, Docker image, first administrator, systemd and updates.
- [Configuration](CONFIGURATION.md) — SQLite or JSON configuration source, configuration map and changes that need a restart.
- [HTTP policy rules](POLICY.md) — named ACLs, maps, variables, HAProxy subset import, header/list operations, stage order and cooperation with existing VCL.
- [HTTP policy rules](POLICY.md) — 40 scenario presets with defaults and previews, condition builder, named ACLs, maps, variables, HAProxy subset import, header/list operations, stage order and cooperation with existing VCL.
- [Headless mode](HEADLESS.md) — proxy and load balancer configured only from a JSON file, without the panel.
- [Troubleshooting](TROUBLESHOOTING.md) — symptom-based checks and a rollout checklist.
## Publishing services
- [Vhosts and backends](VHOSTS.md) — domains, listeners, backends, balancing, health checks and redirects.
- [Vhosts and backends](VHOSTS.md) — domains, listeners, backends, balancing, health checks, redirects and scoped location/ACL/header JSON editors.
- [Custom locations](CUSTOM_LOCATIONS.md) — path routing, request conditions (header, cookie, IP, method, country), whole-host rules, rewrites, local responses and error fallbacks.
- [Load balancing](LOAD_BALANCING.md) — algorithms, consistent hashing by path/header/cookie/query/IP, location backend groups and the distribution simulator.
- [Web Server](WEB_SERVER.md) — static sites, downloads, `try_files`, rewrites, `.htaccess` subset and error pages.
+1 -1
View File
@@ -1,6 +1,6 @@
# VCL import: supported instructions and exact effects
This guide describes the VCL **subset implemented by RustProxy 0.42.0**, not the full Varnish Configuration Language. It is based on the VCL importer and cache-rule engine. Importing VCL **converts statements into graphical cache rules (which must then be saved)**; RustProxy does not execute arbitrary VCL text at request time. Unsupported instructions may be skipped with warnings or cause a parse error; they are not executed as Varnish code. **In the graphical importer, warnings pause conversion:** no rules are added until you explicitly choose **Add partial import (reviewed)**. Even after adding, you must separately save the configuration. The read-only VCL export for ordinary flat rules is a human-oriented preview, **not** a lossless backup or a guaranteed re-importable VCL program. Structured VCL imports use a JSON preview/export that preserves their control flow.
This guide describes the VCL **subset implemented by RustProxy 0.42.1**, not the full Varnish Configuration Language. It is based on the VCL importer and cache-rule engine. Importing VCL **converts statements into graphical cache rules (which must then be saved)**; RustProxy does not execute arbitrary VCL text at request time. Unsupported instructions may be skipped with warnings or cause a parse error; they are not executed as Varnish code. **In the graphical importer, warnings pause conversion:** no rules are added until you explicitly choose **Add partial import (reviewed)**. Even after adding, you must separately save the configuration. The read-only VCL export for ordinary flat rules is a human-oriented preview, **not** a lossless backup or a guaranteed re-importable VCL program. Structured VCL imports use a JSON preview/export that preserves their control flow.
For a short operational reference inside the panel, open **Cache & VCL guide** from **Settings → Cache**, the ordinary **Vhost → Cache** editor or **Docker vhosts → Cache**. The same modal works in all three places; example VCL is pasted into the importer of the editor that opened the guide, and the modal labels that scope. The modal shows the current compatibility-mode, fallback-TTL and grace settings, explains `Vary` and header mutations with examples, and identifies unsupported Varnish hooks. It complements this exact syntax reference; it does not execute VCL or save settings.
+1 -1
View File
@@ -4,7 +4,7 @@
## Practical examples and traffic scenarios
The VCL subset below is preserved in 0.42.0. Optional [HTTP policy rules](POLICY.md)
The VCL subset below is preserved in 0.42.1. Optional [HTTP policy rules](POLICY.md)
add named ACLs, header counts, maps, variables and staged operations alongside
VCL, with explicit integration points. Those native capabilities are not new
VCL syntax and do not imply full Varnish compatibility.
+34
View File
@@ -18,6 +18,11 @@ A **Vhost** publishes one or more hostnames on named HTTP/HTTPS listeners. Its s
A Vhost may bind several frontends. Hostnames and selected listeners must match: the existence of a certificate or an upstream does not create DNS entries or a listening socket. Existing Vhosts retain their bindings when new listeners are created.
The listener choices use aligned cards with the same spacing whether on/off
controls are displayed as switches or checkboxes. Long listener descriptions
wrap inside their cards; this presentation does not change selected listener
IDs or grant access to a disabled listener.
## Cache rules: tester and VCL guide
In **Vhosts → Edit → Cache**, use the same compact **Test a request** form as in global Cache settings and Docker vhosts. The request and example backend response have separate groups. Tests preview the **unsaved local rules** with the **saved global rules** for that vhost (or exclude them if **Ignore global cache rules** is checked). For a path-only URL the current hostname field is used as the `Host` header, unless you specify `Host` explicitly. This simulates rule decisions without contacting the backend and does not model other unsaved cache settings.
@@ -103,6 +108,35 @@ Keep Vhost IDs stable for monitoring/history unless renaming is intentional. Ren
## Editor layout
Since 0.42.1, the Vhost editor no longer has a separate **Advanced** tab. Its
location, inline ACL and custom-header JSON controls live beside their visual
editors:
| Tab and section | JSON drawer | Saved Vhost field |
| --- | --- | --- |
| **Custom locations** | **Locations JSON** | `routes` |
| **Security → Traffic policy → Vhost IP access list** | **Inline ACL JSON** | `acl` |
| **Headers → Custom header rules (request / response)** | **Header rules JSON** | `headers` |
Open the drawer to inspect or edit the same section's data. **Format JSON**
validates and formats the text. **Apply JSON to draft** validates its structure
and updates the visual editor; it does not activate changes. **Reload from
form** reloads the current visual values and asks before discarding unapplied
JSON edits. Save the Vhost after applying the intended changes.
Unapplied or invalid JSON blocks Vhost saving, including when its drawer is
closed; validation reveals the relevant tab and editor. If the same section's
visual form changes while JSON edits are pending, applying them is refused
until **Reload from form** resolves the conflict. Keep a copy of any JSON edits
you want to reapply before reloading. Using `null` for the inline ACL disables
that inline list only; assigned ACL profiles remain independent. Configuration
field names, server validation and access precedence are unchanged.
The **Headers → HTTP policies** editor has a separate rule builder and JSON
view, plus the [scenario catalog](POLICY.md#scenario-presets-and-the-rule-builder).
Its **Documentation** control is a button matching the other editor actions.
Global HTTP policies at `settings?tab=policies` use the same catalog and button.
Within the Vhost editor, **SSL certificates** contains the named certificate selection and the explicit certificate/domain mismatch exception. The next **SSL settings** section contains the optional override of the global TLS 1.2/1.3 and cipher policy. Turning off the TLS override retains the inherited global policy. These two sections are on the same **SSL** tab.
The **Security** tab groups Traffic policy by reusable ACL profiles, HTTP methods, per-IP limits, country access, country-specific limits and User-Agent limits. It also separates HSTS, other security response headers and per-Vhost User-Agent blocking. Since 0.41.0 the **Headers** tab collects everything else about headers: **Backend diagnostics** (Server-Timing, `X-Rust-Proxy-Backend`, backend time and one-click diagnostic header presets), **Response identity and diagnostics** (Server header, request ID) and the **custom header rules** for requests and responses, including `%[variables]`. The tab starts with a live **header preview** of the unsaved draft for both directions (choose an example backend, location and cache result) and marks where every header comes from; rules show the rendered example value or an error while you type. Within **Custom locations → Access**, profile, HTTP method, country and inline IP/CIDR rules are likewise separated. **Details** separates base Vhost properties from WebSocket options; **Backends** separates balancing strategy, retry behavior and keepalive/connection reuse. The visual grouping does not change saved configuration keys or access precedence.