feat(static_files): add static file serving, SPA fallback, rewrites, body rewriting, and auth subrequests

Add static file serving with try_files chain ($uri, $uri.html,
$uri/index.html, fallback), regex-based URL rewrites compiled at
startup, response body find/replace for text/html and JS content,
auth subrequests with header capture for path routes, and custom
response headers per route. Extends RouteConfig with static_root,
fallback, rewrites, body_rewrites, and response_headers fields.

Signed-off-by: Sienna Meridian Satterwhite <sienna@sunbeam.pt>
This commit is contained in:
2026-03-10 23:38:20 +00:00
parent 0fd10110ff
commit 76ad9e93e5
11 changed files with 710 additions and 38 deletions

View File

@@ -99,9 +99,15 @@ fn start_proxy_once(backend_port: u16) {
// without needing TLS certificates in the test environment.
disable_secure_redirection: true,
paths: vec![],
static_root: None,
fallback: None,
rewrites: vec![],
body_rewrites: vec![],
response_headers: vec![],
}];
let acme_routes: AcmeRoutes = Arc::new(RwLock::new(HashMap::new()));
let proxy = SunbeamProxy { routes, acme_routes, ddos_detector: None, scanner_detector: None, bot_allowlist: None, rate_limiter: None };
let compiled_rewrites = SunbeamProxy::compile_rewrites(&routes);
let proxy = SunbeamProxy { routes, acme_routes, ddos_detector: None, scanner_detector: None, bot_allowlist: None, rate_limiter: None, compiled_rewrites, http_client: reqwest::Client::new() };
let opt = Opt {
upgrade: false,

View File

@@ -13,6 +13,11 @@ fn test_routes() -> Vec<RouteConfig> {
websocket: false,
disable_secure_redirection: false,
paths: vec![],
static_root: None,
fallback: None,
rewrites: vec![],
body_rewrites: vec![],
response_headers: vec![],
},
RouteConfig {
host_prefix: "api".into(),
@@ -20,6 +25,11 @@ fn test_routes() -> Vec<RouteConfig> {
websocket: false,
disable_secure_redirection: false,
paths: vec![],
static_root: None,
fallback: None,
rewrites: vec![],
body_rewrites: vec![],
response_headers: vec![],
},
]
}