This commit is contained in:
Mateusz Gruszczyński committed 2026-11-14 17:24:12 +01:00
1 parent 78dbb31487
commit f48843e934
83 files changed
+7304 -1203

No files matched your search

+545 -2
View File
@@ -2,7 +2,7 @@
"openapi": "3.0.3",
"info": {
"title": "RustProxy Administration API",
"version": "0.37.0",
"version": "0.37.1",
"description": "Administration API for the active panel origin. Sign in through the panel; the same-origin HttpOnly cookie authenticates all private operations. Mutations also require the exact Origin, X-RustProxy-Request: 1 and a session-bound X-CSRF-Token. Loopback HTTP is the default; Settings can enable HTTPS before using a non-loopback administration bind. This document contains no live configuration or credentials. Object schemas marked extensible are summaries: full configuration validation is authoritative in Rust. The API also permits explicitly scoped GeneralApiBearer tokens on a narrow route allowlist, with RO/RW and source CIDR checks; API-token management and Prometheus-token management are browser-session-only."
},
"servers": [
@@ -755,6 +755,19 @@
"nullable": true,
"default": null,
"description": "If true, only emit cache diagnostic headers for actual HIT responses, never MISS/BYPASS. null inherits global expose_only_hits. Via is controlled independently."
},
"rules": {
"type": "array",
"maxItems": 128,
"items": {
"$ref": "#/components/schemas/CacheRule"
},
"description": "Vhost cache rules; evaluated before global rules (no vhosts field)."
},
"ignore_global_rules": {
"type": "boolean",
"default": false,
"description": "Skip global cache rules for this vhost."
}
},
"additionalProperties": true
@@ -2412,6 +2425,14 @@
"type": "boolean",
"default": true,
"description": "Default true: ignore only client hard-reload no-cache, max-age=0 and Pragma: no-cache on fresh cache lookups. Preserve client no-store, only-if-cached (504 on MISS), min-fresh/max-stale, origin ETag revalidation and zero-TTL stale-if-error storage. A positive default_ttl_seconds explicitly allows public origin no-cache responses to be reused for that fallback TTL, even without validators; zero keeps validator-only revalidation. Surrogate-Control: no-store and all private/no-store/Set-Cookie/Vary restrictions remain active. Eligible positive-TTL entries without an explicit stale-while-revalidate directive get configurable grace (varnish_grace_seconds, default 60s; explicit =0 is honored). False restores strict browser reload. Switching modes invalidates cache; not full Varnish VCL emulation."
},
"rules": {
"type": "array",
"maxItems": 128,
"items": {
"$ref": "#/components/schemas/CacheRule"
},
"description": "Global cache rules (Cache → Rules)."
}
},
"additionalProperties": false
@@ -3715,7 +3736,7 @@
},
"source": {
"type": "string",
"description": "Discovery sources, for example interface, route, public_api or override."
"description": "Discovery sources, for example interface, route, public_api, override or bridge (container bridge interfaces such as docker0, br-*, podman*, reported since agent 0.37.1)."
},
"interface": {
"type": "string"
@@ -8549,6 +8570,192 @@
"type": "string"
}
}
},
"CacheRule": {
"type": "object",
"description": "Cache rule (since 0.37.1). Request rules run before the cache lookup (vcl_recv/vcl_hash), response rules on a backend response (vcl_backend_response), deliver rules on every response sent to the client (vcl_deliver). Vhost rules run before global rules; for TTL, grace, pass and no_store the first matching rule wins.",
"required": [
"id",
"actions"
],
"properties": {
"id": {
"type": "string"
},
"name": {
"type": "string"
},
"enabled": {
"type": "boolean",
"default": true
},
"stage": {
"type": "string",
"enum": [
"request",
"response",
"deliver"
],
"default": "request"
},
"match": {
"type": "string",
"enum": [
"all",
"any"
],
"default": "all"
},
"conditions": {
"type": "array",
"maxItems": 16,
"items": {
"type": "object",
"properties": {
"field": {
"type": "string",
"enum": [
"host",
"url",
"path",
"extension",
"method",
"query",
"header",
"cookie",
"client_ip",
"status",
"content_type",
"response_header"
]
},
"name": {
"type": "string"
},
"operator": {
"type": "string",
"enum": [
"equals",
"prefix",
"suffix",
"contains",
"glob",
"regex",
"exists",
"cidr"
]
},
"values": {
"type": "array",
"items": {
"type": "string"
}
},
"negate": {
"type": "boolean"
}
}
}
},
"actions": {
"type": "array",
"minItems": 1,
"maxItems": 16,
"items": {
"type": "object",
"description": "type: pass, strip_cookies{keep}, strip_query{params,keep_only}, hash_header{name}, hash_cookie{name} (request); ttl{seconds}, grace{seconds}, no_store, ignore_cache_control, strip_set_cookie (response); set_header{name,value}, remove_header{name} (deliver).",
"additionalProperties": true
}
},
"stop": {
"type": "boolean"
},
"vhosts": {
"type": "array",
"items": {
"type": "string"
},
"description": "Global rules only: limit to these vhost ids (empty = all)."
}
}
},
"CacheRuleTestRequest": {
"type": "object",
"required": [
"request"
],
"properties": {
"vhost_id": {
"type": "string"
},
"global_rules": {
"type": "array",
"items": {
"$ref": "#/components/schemas/CacheRule"
}
},
"vhost_rules": {
"type": "array",
"items": {
"$ref": "#/components/schemas/CacheRule"
}
},
"ignore_global_rules": {
"type": "boolean"
},
"request": {
"type": "object",
"properties": {
"method": {
"type": "string"
},
"url": {
"type": "string"
},
"headers": {
"type": "array",
"items": {
"type": "array",
"items": {
"type": "string"
}
}
},
"client_ip": {
"type": "string"
}
}
},
"response": {
"type": "object",
"properties": {
"status": {
"type": "integer"
},
"headers": {
"type": "array",
"items": {
"type": "array",
"items": {
"type": "string"
}
}
}
}
}
}
},
"CacheVclImportRequest": {
"type": "object",
"required": [
"vcl"
],
"properties": {
"vcl": {
"type": "string",
"maxLength": 262144
}
}
}
}
},
@@ -15374,6 +15581,342 @@
}
}
}
},
"/api/cache/rules/stats": {
"get": {
"summary": "Cache rule match counters",
"tags": [
"Cache"
],
"operationId": "get_api_cache_rules_stats",
"responses": {
"200": {
"description": "Match counters keyed by global:<id> or vhost:<vhost>:<id> since process start",
"content": {
"application/json": {
"schema": {
"type": "object",
"additionalProperties": true
}
}
}
},
"401": {
"description": "Authentication required or revoked",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"403": {
"description": "Host, origin or CSRF validation failed",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"429": {
"description": "Bounded worker/session/rate limit",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"503": {
"description": "Control-plane storage/worker unavailable",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
}
},
"security": [
{
"AdminSession": []
},
{
"GeneralApiBearer": []
}
]
}
},
"/api/cache/rules/test": {
"post": {
"summary": "Simulate cache rules for a request",
"tags": [
"Cache"
],
"operationId": "post_api_cache_rules_test",
"description": "Evaluates saved or draft global/vhost cache rules for a test request (and optional backend response) without sending traffic or counting matches. Returns matched rules per stage, overridden rule actions, the rewritten URL, cookies, cache key variants, TTL/grace and the cache decision.",
"parameters": [
{
"name": "Origin",
"in": "header",
"required": true,
"schema": {
"type": "string"
},
"description": "Exact http://HOST:ADMIN_PORT. Set automatically by same-origin browser POST/PUT/DELETE."
},
{
"name": "X-RustProxy-Request",
"in": "header",
"required": true,
"schema": {
"type": "string",
"enum": [
"1"
]
}
}
],
"security": [
{
"AdminSession": []
},
{
"GeneralApiBearer": []
}
],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/CacheRuleTestRequest"
}
}
}
},
"responses": {
"200": {
"description": "Simulation result",
"content": {
"application/json": {
"schema": {
"type": "object",
"additionalProperties": true
}
}
}
},
"400": {
"description": "Invalid request",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"401": {
"description": "Authentication required or revoked",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"403": {
"description": "Host, origin or CSRF validation failed",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"413": {
"description": "Request exceeds the endpoint body limit",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"422": {
"description": "Configuration/input validation failed",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"429": {
"description": "Bounded worker/session/rate limit",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"503": {
"description": "Control-plane storage/worker unavailable",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
}
}
}
},
"/api/cache/rules/import-vcl": {
"post": {
"summary": "Convert a VCL subset into cache rules",
"tags": [
"Cache"
],
"operationId": "post_api_cache_rules_import_vcl",
"description": "Parses vcl_recv/vcl_hash, vcl_backend_response/vcl_fetch and vcl_deliver and converts supported statements into cache rules. Unsupported statements are returned as warnings; nothing is saved.",
"parameters": [
{
"name": "Origin",
"in": "header",
"required": true,
"schema": {
"type": "string"
},
"description": "Exact http://HOST:ADMIN_PORT. Set automatically by same-origin browser POST/PUT/DELETE."
},
{
"name": "X-RustProxy-Request",
"in": "header",
"required": true,
"schema": {
"type": "string",
"enum": [
"1"
]
}
}
],
"security": [
{
"AdminSession": []
},
{
"GeneralApiBearer": []
}
],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/CacheVclImportRequest"
}
}
}
},
"responses": {
"200": {
"description": "Imported rules and warnings",
"content": {
"application/json": {
"schema": {
"type": "object",
"additionalProperties": true
}
}
}
},
"400": {
"description": "Invalid request",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"401": {
"description": "Authentication required or revoked",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"403": {
"description": "Host, origin or CSRF validation failed",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"413": {
"description": "Request exceeds the endpoint body limit",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"422": {
"description": "Configuration/input validation failed",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"429": {
"description": "Bounded worker/session/rate limit",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"503": {
"description": "Control-plane storage/worker unavailable",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
}
}
}
}
},
"tags": []