This commit is contained in:
Mateusz Gruszczyński committed 2026-11-26 15:19:21 +01:00
1 parent a75893d428
commit bfbeedfad7
43 files changed
+5834 -125

No files matched your search

+1 -1
View File
@@ -55,7 +55,7 @@ New Vhosts store an explicit `authentication` choice; old Vhosts with only `tiny
### Existing integrations
- **Basic Auth:** protect selected Vhosts with configured credentials. Use HTTPS so credentials are not sent over plaintext.
- **Basic Auth:** protect selected Vhosts with configured credentials. Use HTTPS so credentials are not sent over plaintext. RustProxy performs memory-hard Argon2 verification for each HTTP request, including static assets. Up to two checks run simultaneously; additional checks wait in a bounded per-Vhost queue (64 queued requests, at most 3 seconds). When the queue is full or the deadline expires, RustProxy returns HTTP 503 with `Retry-After: 1` and logs a warning instead of silently dropping the request. A 401 means missing or invalid credentials, and 429 means too many failed attempts from one IP. If parallel assets fail with 503, inspect `error.log` for `Basic Auth` verification queue warnings rather than changing filesystem permissions or FastCGI sockets.
- **Tinyauth:** add a verification URL and an HTTPS login URL. RustProxy makes a bounded, body-free authorization request and can pass specifically allowed identity headers upstream. An origin URL automatically uses `/api/auth/nginx` (or set that path explicitly). This Nginx auth-request integration sends `X-Original-URL` and `X-Original-Method`, with a validated `X-Forwarded-For` and `X-Real-IP` for Tinyauth IP ACLs. It does **not** send `X-Forwarded-Host` or `X-Forwarded-URI` to the verifier, avoiding the `conflicting auth module headers` rejection introduced in Tinyauth 5.2.0 while keeping compatibility with earlier versions that implement the Nginx endpoint. Tinyauth has its own timeout and private-backend policy.
- **Provider-neutral gateway error pages:** One embedded `src/admin/web/error_auth_provider.html` template renders a self-contained HTML page for **Tinyauth, Authelia, authentik, and future providers**, using only the safe provider display name and the failure category. It replaces the three vendor-specific `error_tinyauth_*.html` source files while preserving the familiar Tinyauth response titles and statuses. For example: `502 Tinyauth connection error` if its HTTP client cannot reach Tinyauth (DNS/TCP/TLS/transport), `504 Tinyauth timeout` if the auth deadline expires, or `502 Tinyauth verification error` for unexpected verifier status or invalid/oversized data. The page always retains the HTTP error status, `Content-Type: text/html; charset=utf-8`, `Cache-Control: private, no-store` and `X-Content-Type-Options: nosniff`. Backend URLs, protocol errors and identity data are not shown to visitors. All of these cases **deny access** to the protected origin. HTTP `401`/`403` and configured login redirects remain unchanged. These auth-specific pages take precedence over custom Vhost/general HTTP error pages so the failure remains distinguishable. The generic failure marker also protects Basic Auth denials and provider login redirects from being replaced by Vhost pages. HTTPS-verifier transport errors are classified as connection failures, truncated/oversized/invalid verifier responses as verification failures, and verification deadlines as timeouts.
- Point the verifier URL **directly** at the private Tinyauth service (for example `http://tinyauth:3000/api/auth/nginx`), rather than routing it through a second public proxy that might inject conflicting headers. Do not disable Tinyauth's header-spoofing protections. Confirm that Tinyauth trusts only the actual RustProxy address/network when enabling Tinyauth IP-based access controls (`TINYAUTH_AUTH_TRUSTEDPROXIES`).
+2
View File
@@ -38,6 +38,8 @@ The current bundled `src/admin/openapi.json` declares these operations (among ot
| `GET /api/dashboard-presets` and named preset operations | Saved Overview presets. |
| `GET /docs/openapi.json` | Protected machine-readable API specification. |
The page kind `cloudflare` selects offline, pre-generated HTML/CSS templates in 0.42.3 for global pages, Vhost error pages and 404 hosts; see [Error pages](ERROR_PAGES.md). Existing JSON types and HTTP semantics are unchanged.
Some paths have additional DELETE/PATCH operations, job-status resources, query parameters or restricted actions. Use OpenAPI for the **actual fields/methods**, not guesses based on a table. `GET /metrics` here is not a replacement for the separate Prometheus exporter.
The full and live status responses include `metrics.cache_request_outcomes` (`hits`, `misses`, `bypasses`, `other`) and `metrics.completed_success`. Full and live `GET /api/cache` include `request_outcomes`, using the same process counters. These are final client-request classifications; existing `cache` / Cache `metrics` fields remain technical operation counters. Domain outcomes count final requests, while diagnostic reasons can include separate refresh and collapse events.
+47
View File
@@ -0,0 +1,47 @@
# Error pages: built-in, Cloudflare-style and custom
From **RustProxy 0.42.3**, administrators can choose a **Cloudflare-style (offline)** page alongside the existing built-in, blank, placeholder and custom HTML responses. This does not turn Cloudflare into an upstream or contact its servers.
## Where to select a page
- **Settings → Pages:** select `Cloudflare-style (offline)` for an individual HTTP error code, or for the direct-IP and unknown-host response. **Switch all to Cloudflare style** sets both host-level pages plus all 11 configurable global error codes in the **draft**. Select **Validate, save and apply** to publish. This does not rewrite any per-Vhost overrides.
- **Vhost → Pages:** select it for a custom error response or a missing-path fallback. **Switch all to Cloudflare style** changes response, fallback and all 11 supported error codes for **this Vhost**; it also enables application-error interception for those codes so origin 4xx/5xx responses use the selected pages. **Validate, save and apply** saves the Vhost. The button does not change other Vhosts.
- **404 hosts → Response type:** choose `Cloudflare-style (offline)` and a supported error status.
Existing configuration stays unchanged until an administrator explicitly selects a template or uses the new bulk button and saves. A bulk button changes only the current form draft; it does not save automatically. The per-Vhost bulk action intentionally enables interception of supported origin errors for that Vhost. A per-Vhost page takes precedence over the corresponding global error page. Authorization provider responses/redirects remain protected by the existing authentication flow.
## Supported pages
The directory `src/admin/web/cf_page/` contains generated HTML files for `200, 400, 401, 403, 404, 408, 410, 413, 429, 500, 502, 503, 504`. Global error replacement supports `400, 401, 403, 404, 408, 413, 429, 500, 502, 503, 504`; other supported statuses apply to local responses/404 hosts where relevant. An unsupported standalone status displays RustProxy's normal built-in response.
Each page contains the corresponding HTTP code, heading, three-node diagnostic visualization and short next-step advice. The layout follows the familiar light header, gray status band, green/red indicators and two help columns of the [cloudflare-error-page](https://github.com/donlon/cloudflare-error-page) reference project, with a dedicated **RP** mark instead of Cloudflare's cloud. The static HTML contains no Cloudflare links, logos, Ray IDs, fake origin-health checks, or service-ownership claims. Status icons describe the request's handling, not actual live health telemetry. The footer uses minimal **RustProxy** branding instead of a lengthy disclaimer.
## How it works
`src/pages/mod.rs` uses `include_str!` references to the pre-generated HTML files, **exactly like the existing `src/admin/web/error_*.html` templates**. HTML and CSS are contained in each file. There are no external fonts, images or scripts, no network requests, no runtime filesystem reads and no newly introduced binary/static-file server.
Existing status overrides in the form are preserved by the bulk action; choosing a page style does not silently change the HTTP status. The original HTTP status is preserved for intercepted errors. Served pages have `Content-Type: text/html; charset=utf-8`, `Cache-Control: no-store`, and `X-Content-Type-Options: nosniff`. Existing challenge headers (such as `WWW-Authenticate`) are retained. Invalid page combinations are rejected during config validation. Edits to embedded templates require rebuilding RustProxy, while switching the selected page kind is a normal live configuration change.
## Example JSON
Select the template for one global HTTP status without changing other error pages:
```json
{
"pages": {
"errors": {
"502": { "kind": "cloudflare", "status": null, "html": "" }
}
}
}
```
This is a fragment of configuration, not a complete replacement document. In the panel, set **Settings → Pages → 502 → Cloudflare-style (offline)** and save the section.
## Verification
```sh
curl -i https://your-host.example/nonexistent
```
Check the actual HTTP status and response markup. For a 502 page, first configure interception or a matching generated error, then confirm the body shows `502 Bad gateway` and `RustProxy`. Re-test `401` with Basic Auth to ensure the challenge header remains. No Cloudflare account or public network access is needed.
+1 -1
View File
@@ -17,7 +17,7 @@ RustProxy is a single service that combines a reverse proxy, a static/PHP web se
| 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. 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 |
| Redirects and pages | Redirect hosts, canonical host and HTTPS redirects, 404 hosts, custom error pages, offline Cloudflare-style static error templates with one-click per-scope selection and direct-IP pages |
| TCP/UDP Streams | Layer-4 forwarding with backend pools, health checks, session limits and idle timeouts |
## Frontends and TLS
+1
View File
@@ -26,6 +26,7 @@ Guides for operating RustProxy: installation, publishing services, security, cer
- [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.
- [Error pages](ERROR_PAGES.md) — built-in and offline Cloudflare-style status templates, selection and HTTP semantics.
- [FastCGI and CGI](FASTCGI.md) — generic PHP-FPM, fcgiwrap and FastCGI responder configuration; Vhost mounts, scripts, identity, tests.
- [PHP-FPM](PHP_FPM.md) — PHP profiles, pool isolation and application examples.
- [HTTP transport and TLS](TRANSPORT.md) — HTTPS, HTTP/2, HTTP/3, WebSockets, backend protocols and post-quantum key exchange.
+1 -1
View File
@@ -100,7 +100,7 @@ The **Redirects** and **404 hosts** editors distinguish host identity/domains fr
- WWW controls can direct `www.example.com` to `example.com` or the opposite as supported by the editor; ensure DNS/certificate coverage for both.
- Use the dedicated **Redirects** workspace for redirect-only domains. Use **404 hosts** to claim a hostname and return a local not-found page without forwarding.
- **Custom locations** may return status/body or redirect for selected paths. **Internal locations** can be used as fallbacks for configured `403/404/500/502/503/504` application responses.
- The **Pages** section can replace supported origin error bodies without contacting a second backend. This keeps the response status and disables caching of the replaced error body.
- The **Pages** section can replace supported origin error bodies without contacting a second backend. This keeps the response status and disables caching of the replaced error body. Since 0.42.3, it also offers a static, offline **Cloudflare-style** page option; see [Error pages](ERROR_PAGES.md).
## Safe operating practices
+2
View File
@@ -93,6 +93,8 @@ Missing static files return **HTTP 404 Not Found**, unreadable/blocked paths **4
These generated HTML responses retain the actual HTTP status, `Content-Type: text/html; charset=utf-8`, `X-Content-Type-Options: nosniff` and `Cache-Control: no-store`; `HEAD` preserves the matching `Content-Length` but sends no body. Explicit application/origin responses are still passed through without forced replacement, subject to the Vhost error interception options below.
Since 0.42.3, **Settings → Pages** and **Vhost → Pages** can also select a pre-generated offline Cloudflare-style template for individual error statuses. These HTML/CSS files are in `src/admin/web/cf_page/` and are served by the same `include_str!` mechanism as existing built-in pages; nothing is read from disk at request time. See [Error pages](ERROR_PAGES.md) for selection, scope and limitations.
Vhosts can intercept selected application error bodies in **Pages** and return a configured HTML error page while preserving the status. Internal location `error_fallback` is different: it routes the error to a named internal handler. Error-page replacements are marked uncacheable. Origin-supplied and explicitly configured custom error bodies are preserved unless interception is enabled.
## Monitoring and issues