From f38a2b9e5e49bb315a922c9d677e58bdf6a3d0b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Gruszczy=C5=84ski?= Date: Thu, 26 Nov 2026 11:02:46 +0100 Subject: [PATCH] v0.42.2 --- AGENTS.md | 2 +- CHANGELOG.md | 8 + Cargo.lock | 2 +- Cargo.toml | 2 +- README.md | 2 +- SHA256SUMS | 73 +++---- docs/CUSTOM_LOCATIONS.md | 2 +- docs/FASTCGI.md | 110 +++++++++++ docs/FEATURES.md | 2 +- docs/PHP_FPM.md | 2 +- docs/README.md | 1 + docs/WEB_SERVER.md | 12 +- langs/en_US.json | 36 ++-- langs/pl_pl.json | 36 ++-- src/admin/documentation/documents.rs | 1 + src/admin/openapi.json | 69 ++++++- src/admin/router.rs | 1 + src/admin/status_live.rs | 9 + src/admin/web/index.html | 39 ++-- src/admin/web/web-server-profiles.js | 36 +++- src/admin/web/web-server.js | 61 +++++- src/basic_auth/mod.rs | 7 + src/config/snapshot.rs | 10 +- src/config/tests.rs | 26 +++ src/proxy/forward/web_source.rs | 9 + src/proxy/web_cache_revalidation/tests.rs | 1 + src/web_server/config/compile.rs | 34 +++- src/web_server/config/model.rs | 18 ++ src/web_server/config/validation.rs | 20 +- src/web_server/fastcgi/protocol.rs | 12 +- src/web_server/fastcgi/response.rs | 17 +- src/web_server/htaccess/model.rs | 115 ++++++++++- src/web_server/htaccess/parse.rs | 184 +++++++++++++++-- src/web_server/htaccess/rewrite.rs | 31 +++ src/web_server/mod.rs | 2 +- src/web_server/request.rs | 2 + src/web_server/serve.rs | 33 ++-- src/web_server/tests.rs | 231 ++++++++++++++++++++++ 38 files changed, 1098 insertions(+), 160 deletions(-) create mode 100644 docs/FASTCGI.md diff --git a/AGENTS.md b/AGENTS.md index 95a1cb8..704654a 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -1,6 +1,6 @@ # RustProxy source and documentation maintenance -Current source version: **0.42.1**. The Cargo package and binary are named `rust-proxy`. +Current source version: **0.42.2**. The Cargo package and binary are named `rust-proxy`. Before editing, read [README.md](README.md), the relevant [documentation guide](docs/README.md) and the actual code and tests. Historical release experiments are not current specifications. Use the bundled `src/admin/openapi.json` for API routes and payloads; the source implementation is authoritative for runtime behavior. diff --git a/CHANGELOG.md b/CHANGELOG.md index 0ecd9b6..6a7d655 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,14 @@ Release history focused on **features, settings, default behavior, compatibility and fixes**. Changes to internal code structure and preliminary performance experiments are intentionally omitted. Historical descriptions reflect their respective releases; consult the current documentation for the settings available in the latest release. +## 0.42.2 — Generic FastCGI/CGI hosting and Apache compatibility + +- **Legacy Apache access rules:** compile and enforce `Order`, `Allow from` and `Deny from` for `all`, IP addresses and CIDR networks (IPv4/IPv6), including `Deny from all`, rather than rejecting them independent of Strict mode. This preserves access restrictions. Unsupported security and handler constructs still fail closed; non-security unsupported directives remain warnings when Strict is off. +- **Panel:** clarify that turning Strict mode off does not disable security rules. Show per-Web-Service skipped .htaccess directives with file and line from the compiled configuration; diagnostics are also logged as warnings. +- **Universal FastCGI handlers:** Web Services support `php.handler=php_fpm` (default for existing configurations), `fcgiwrap` (external CGI runner), or `fastcgi` (generic responder). Socket/loopback TCP endpoint, executable extensions, `SCRIPT_NAME` public mount prefix, PATH_INFO, streaming bodies and bounded headers/timeouts are configurable independently per Web Service or shared profile. Verified Vhost Basic Auth identity can populate `REMOTE_USER` and `AUTH_USER`; reserved CGI identity and script parameters are never accepted as untrusted custom overrides. A CGI-only Web Service refuses raw static file delivery. No application-specific filesystem or URL paths are hard-coded. +- **Popular `.htaccess` migration rules:** add `Redirect`, `RedirectMatch`, and bounded `` / `` access-control blocks. Access control is enforced on direct script paths and index files rather than skipped. Unsafe/unknown authentication or execution rules remain fail-closed. +- **Docs and compatibility:** add a generic [FastCGI / CGI guide](docs/FASTCGI.md) with PHP + CGI + static routing examples and an Angie/Nginx-to-RustProxy mapping; update the panel, EN/PL labels, Reader, OpenAPI and regression tests. Existing `php` JSON and profile IDs remain valid. These source changes still require Cargo compilation and real PHP-FPM/fcgiwrap integration tests before production deployment. + ## 0.42.1 — HTTP policy scenarios and editor improvements - **Scenario presets:** the shared HTTP policy editor replaces the two standalone Vary preset buttons with a searchable, grouped catalog of 40 practical scenarios built from 54 rules. Recipes cover header cleanup, CORS, browser security, private/signed/preview requests, cache TTL/grace and revalidation, event streams, access filters, redirects, path rewrites, maintenance, backend selection and transaction diagnostics. Descriptions, setup notes and rule previews show each recipe's effect; configurable or sensitive additions start disabled. Location scope offers 39 scenarios because `pre_route` rewriting precedes location selection. Adding a scenario appends uniquely identified draft rules; saving the containing form activates enabled rules. diff --git a/Cargo.lock b/Cargo.lock index b7a6be5..f6a6cd4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1914,7 +1914,7 @@ dependencies = [ [[package]] name = "rust-proxy" -version = "0.42.1" +version = "0.42.2" dependencies = [ "anyhow", "arc-swap", diff --git a/Cargo.toml b/Cargo.toml index 83b6ad6..90ecd07 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rust-proxy" -version = "0.42.1" +version = "0.42.2" edition = "2021" rust-version = "1.99.1" description = "RustProxy - independent reverse proxy with local administration" diff --git a/README.md b/README.md index 02b1f06..6351f43 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ | --- | --- | | Reverse proxy | HTTP/HTTPS backends, HTTP/1.1, HTTP/2 and H2C upstreams, load balancing, health checks, connection reuse, WebSockets, custom locations, retries and error fallbacks | | Frontends | HTTP, HTTPS, HTTP/2, HTTP/3 (QUIC), named listeners, exact and wildcard domains, redirects, optional post-quantum TLS key exchange | -| Web Server | Static sites and downloads, `try_files`, rewrites, `.htaccess` subset, byte ranges, precompressed files, PHP-FPM | +| Web Server | Static sites and downloads, `try_files`, rewrites, `.htaccess` subset, byte ranges, precompressed files, external PHP-FPM, CGI via fcgiwrap and generic FastCGI responders | | Certificates | PEM import, ACME HTTP-01 and DNS-01 (Cloudflare, OVH, RFC 2136), automatic renewal, external Certbot files, hot reload | | Access | IP/CIDR, DNS/DDNS and country rules, ACL profiles, rate limits, method and Content-Type policies, Basic Auth, Tinyauth, Authelia, authentik, OIDC | | Delivery | Shared memory and disk cache, `Cache-Status`, purge/ban, gzip/Brotli/Zstandard compression, asset minification | diff --git a/SHA256SUMS b/SHA256SUMS index df28e37..40b7dca 100644 --- a/SHA256SUMS +++ b/SHA256SUMS @@ -1,13 +1,13 @@ 61bf40a0572889dc8b0dda9eae4e93e44b0de9364b3c798106c85700ffb37c23 .dockerignore 4140a2956264b44f259e6a37fc00ba02097bbe68b09296e04d3d243c1287129b .env.example 0a5e87541831edca0e7164c6469dba01a8a7053ab14dbfb8019c83e4db10edc2 .gitignore -1b9b764f579ce64485c2b2c9b0d717eb1875ac0c2aa86df2a24bcce16456ac54 AGENTS.md -f0b2ce9432c0c742bb528941a1b394ebd245822b2e3ec909d9e5cb56787a53b6 CHANGELOG.md -aaf6d97af6fe4dc5a983fbc347934a50f20ce12beee6ffb9c681ec353794166f Cargo.lock -1249af090f77e46e1cb1bb5bc2fcf22be7781b86fc9fccf626dc73e5b6e7c75f Cargo.toml +3c4638dc086333b8383c5bc77fe967b790075439f5e7a8257e5dd0dd4cf4233b AGENTS.md +b446765161f494e1e07196bcec6f6edcc8e42216bed8b8ad6dfc58a0136eb89e CHANGELOG.md +c28d825120a878684b511b1a6a4f372aced5098ed7b9bec8b318c4ec3fb1cbf4 Cargo.lock +3ac98730af5caa39f81d28f4a4f7f14710fbb53d625794dd5704e65afebe4d8e Cargo.toml 788745d4f70a0382c6280020afbd48844bb2af65e835a826852143f8132cdeca Dockerfile 0d96a4ff68ad6d4b6f1f30f713b18d5184912ba8dd389f86aa7710db079abcb0 LICENSE -6889fb8bc1edbb5aae65ec7a799270e2028ad6625f8c38488f3cb25d437e8c6c README.md +b3f2518300e2e057eed893b290140da0f01db4c31740fc8e6d69254f4b7ae22b README.md da8311e3db945290666324a2f24bf4521b365272d7ac3f862ded1be993eea646 UPDATE_CHECK.toml 120609370b79e192c9a2a72c1706225aa5da06c5806efa26a010b733e120322b build.rs 95ececaba550a4bcfd6754073877ba0633373b1e1451521b9ac905a51e8ca6eb deploy/README.md @@ -45,10 +45,11 @@ bfe96dd91dfc6e07918a662d98b036f12ceb011a5aa8381b3778bd0c964b19ab docs/CACHE.md 51d34823d139ff3b0b8e1cf1a31850746be5ed7da847a2cca51be36fd5f7733a docs/CACHE_TEMPLATE_LIBRARY.md 31285f000cf725d018a926023fe608fec983b959053f7a55e0954b962a8bc20c docs/CERTIFICATES.md 81df6715e2f07617fe0bbb0960c4d5bdac28cf665ce7297fa3768118e6ab28ba docs/CONFIGURATION.md -209664f5937d88c857aab2db3ced9fdfc264b526671ef59b999a00c5d7678aa3 docs/CUSTOM_LOCATIONS.md +966a1c49274c45568cf2b34158900524471f50d796d227a02db49c57941cc808 docs/CUSTOM_LOCATIONS.md 16d4510e38d43c3bbde9b7dab7af3aeb0cb837dc2f1956cfaad7a9a11bea3bfc docs/DASHBOARD.md 53cb0ce7db5ce25e4c2381de3a6e875d212deeed08861da63050de6c51a442bd docs/DOCKER_DISCOVERY.md -f42182261c07849fe3a19be72cc71305175ce33524bdaf791ed8d66656d96e2b docs/FEATURES.md +6b575c6c1c7e01b252bbbf441ab100745dace3799f70fd65b840cba4681d1c08 docs/FASTCGI.md +e7c5ec82c5a0ec336fa7e88835f82925bb75f213975309853a3d748b28f1b6b2 docs/FEATURES.md f7bb59821e0d6c45ae2a1789086fd9dab33d91c0ceae784ae68f64bd13b5f496 docs/HEADLESS.md bce732d845c23ad677ae811e7529b9322ab41d04ca808e04087d0f76bccd9309 docs/INSTALL.md 3268808766ad66263e465f251dce18cff2e7ede355638dc2b0975870b1a5eead docs/LOAD_BALANCING.md @@ -56,9 +57,9 @@ bce732d845c23ad677ae811e7529b9322ab41d04ca808e04087d0f76bccd9309 docs/INSTALL.m 3b889851ba3405247861391aefbcfcaa5a96cf9b09b3e0e0e412ec2f54e11b1a docs/MIGRATION.md 48105c4303401aa99ffff00d3ebaf3024535a492a4a7b883c6803e4732b37434 docs/MONITORING.md 6d3937088eeb67a9f690d44ebe0b6e660b68116dbf69091ac7816bdc52cec2b6 docs/PERFORMANCE.md -d5894c07c68ec4230987767198434abee13b0e525842fea21bcbe752fa82742b docs/PHP_FPM.md +a8fdd52601f45a19fd194e27d6ce40aaf57603e88633f8d7040775599494e124 docs/PHP_FPM.md 45ce24998bda40e60f34756bef29616114aec9fd5cdd5e1aed692ff2371a3af1 docs/POLICY.md -28f4c4faa850dc13e9431eeec2a3c776f227f6839d071dc0baeab7e50c3faa38 docs/README.md +e41b45ff1f980be556d866d7ebb619ab5b455dccf3683519e937e0fb418fbc99 docs/README.md e90842a75459ddb5892334f66a4139d9301280b4d0c17077d211749bd7c90d80 docs/RESPONSE_DELIVERY.md 95ab4786792d5920a2e109b7d196838057f24b512a69d713fb5884dc75c84339 docs/SCREENSHOTS.md 3a48184b36d225757fc5e2d22c629f89bfe5d4007ff087f0be0ce02a5fb04c28 docs/SECURITY.md @@ -70,7 +71,7 @@ c4407cbd70d181e87f64e8d1736624d7b8b59a04b915ad3464f0e1f16d474e99 docs/TRANSPORT 4a5534b628c18f4e83c67c6136b60969c884391fbe55cc6bd4f2354711d8ffb7 docs/VCL_SUPPORT_MATRIX.md 382e084a1f9e35627ccb43eaf451c18fb6d0cc752397c2178108d71de592a931 docs/VCL_TRAFFIC_COOKBOOK.md 181444ea2c28171ed89ead25dcfc60ee6bd05f7b01c1a49d8248a307dc9be7a4 docs/VHOSTS.md -495c9977cb24995acb8cc846bd18cedc3957ab262c5134362bb0e9c9d2246680 docs/WEB_SERVER.md +720d4bf8ba2bfd502de98fa2fc9df97d7155e36f10e7106238646fed8a5f19ff docs/WEB_SERVER.md 42822b1c9801bcadb0e2d785cb91883ca2df1da141222631f153030c95f5e197 docs/images/about.png deff2393a987ac7102179dc85b48baf2c4a3882291bb8c7c584d760cc497c631 docs/images/api.png 74df8228ea6283004b3e87b4d297e43637371eb4a700b69c7248114c8670777a docs/images/cache.png @@ -136,8 +137,8 @@ e9cbb0224c4a3d23a6019ba557e0cd568c1ad5e1582ff1e335fb7d99b7a1055d integrations/r 3f092a9ab80221eddd67be4d1a776acbc6e04c1eb6011b588280c28e83b2582f integrations/routeros-oci-build/build-routeros-oci.sh 3f267cafa16006e5456ade78ee2d5fae02cc7ce747839523068ffd8d7c98798a integrations/routeros-oci-build/docker-entrypoint.sh ae2ee2887fcba096d0de25edcc18faa1ffec35759274518db1bf6d6982f7176c langs/README.md -fd79669fb238461aac1953c3103770b58eb4e405a48a164eada45e85d27ab085 langs/en_US.json -96f0f4349d4f524bcba80ee11ce2ce568dc5fca98910f8958007179ea3f6deb7 langs/pl_pl.json +15cd8725e17d0f9ce60423574ed7405f68f25697247987cae048ddda71eb2075 langs/en_US.json +4947f1cbff86adb68ad840cae65a27f5ad553fc0273af2b3fbea974509a32191 langs/pl_pl.json 38773ed251a8c24af353f4744e498ae2bc7d4151df7927e942c4ac223f6008e1 make_zip.py e830d37dd1f81a4b0aa7d535f5bba69e34e433b0fd99cc8ee0b296786c32379a migrations/0002_admin.sql 20112cc82192098b8d602f1c4f7ca08712e9e1366c845fabb92753187c370d35 migrations/0003_certificate_renewals.sql @@ -203,7 +204,7 @@ f73678bfa4c4f92779cf4e8ae2feb37419de320fb1b53111c982539d5761dbcf src/admin/aler 11f1501574e4042fab7a97f18a19c8a69856e157933a56baaf4c7cc9d2da9a8c src/admin/config_sections.rs c51f725075b5c4fc3fb7fb8b8b5f73987bff698a400e8950e968068b97a77631 src/admin/dashboard_presets.rs aae1ca0e70d987830bd63948d431f54302083148177c1b551565be12df7fe771 src/admin/documentation.rs -4191044a22ec0013937dda3241837b2ac9a03b615717f09996566de7eb1a22d3 src/admin/documentation/documents.rs +ea34f2681a8077b7630dba9c35bc9e0f3711c5d5027c2803c44f5d84a0b3e2cb src/admin/documentation/documents.rs f9b2c8fe62cc92d7693e46145b2543b12dd6d4943fe2d52c67ed6958d4af83de src/admin/documentation/tests.rs 1ce779b84aa8f47bdb3c34f83593c1f2f06d2235f0319847096cfcd035434168 src/admin/file_log_search.rs 2805c7d1c08fed6a54711b8b5d51078ba8c2daecae431b6c7c39fe0345b6cecc src/admin/file_logs.rs @@ -211,7 +212,7 @@ f9b2c8fe62cc92d7693e46145b2543b12dd6d4943fe2d52c67ed6958d4af83de src/admin/docu e2253599b5e39510946729920d240711403a3889cc495eb49824296228f1d080 src/admin/file_logs_query.rs 1594c8666991c1d07487a6a718211ef404cf49114721960f7e119bb7f605e3d2 src/admin/logging_api.rs 781fd5f176dd8f2372f75bd90edcf160708e2d0a8d6a115ba4b283c0cd49eb2d src/admin/mod.rs -c0780d0016315050b7d487f48a55a056b1a58ac013d02f2a3ef30c7c73ddd527 src/admin/openapi.json +7db46bdbef37c8295d7aee2c0d9150ccd51c30ca6fd2af9f859785766b8e926d src/admin/openapi.json 9f8842cdec27d703d1795dd6eb37d9420e9f5a2e56a0df93278c92bace5d1f4c src/admin/operations.rs 257d93a29d0bda96462bcf695aba8d0ec0f9412c379e066ec46ae8ee034e3a53 src/admin/panel_assets.rs f5127855c2994d052678865df36d703b74f4a0afc633daf7718b10da18d26e37 src/admin/panel_content.rs @@ -223,10 +224,10 @@ ea202c67d9acb7614046f153beecdff10d5822b3d5627eaf2ebda33954b36474 src/admin/pref 62ecbae5dee00aeeca3eb806e2605372471dfab971cde8f66f11e711df8fcea1 src/admin/public/mod.rs 7a00e4ab943f74d2b1bdcbfab7f9cd3f584e9f59536b4aca6c4c31f5f5508d12 src/admin/public/tests.rs 6930b4f4b45257772b321b20a9becdf9bc4610274852948ba38c2d0cdf02dfaf src/admin/refresh_preferences.rs -7a680e100aec9ad68b360ed23d364e755915b6a810cacbd82890e8d99856187f src/admin/router.rs +8df90dffdbdb14e068d26f2a81801a76c69ec0bb65a9d13a4cae7bdf367be6cd src/admin/router.rs fba52102e77ca8871a42f97c91be8f10a9aa4f997868652d550fff3fbd41b66e src/admin/session.rs 1c4d04b14a508fca7537f54e660124f4dae1964b48d7bd3b878ec4faa7156805 src/admin/status.rs -9b5bc1a439c5e5611c47732fe86097877b50b09b10a0838d9813314ea6232d0c src/admin/status_live.rs +bac2116e9a7d5f19a112565e1483787ff6102f489bed0cb3b0b3e2102ddd3edb src/admin/status_live.rs c20f214e2ec2a14d8a88d07a63a27d9396a7a6bf9446f6ee31dbd77b12e4b585 src/admin/status_system.rs ea1d0b8ff69157215f9358f0de35b91462ab2bf1fb97f9ce9b37846d0432c56b src/admin/tail.rs b4bcfb9fc989d5586ca3d82e8b5777c306e9a6720f9ec011d09bd786db9faf49 src/admin/tests.rs @@ -301,7 +302,7 @@ e6c4d91d1542d0a5b47bb8736f9539d43a6713df5a473b635519d5b7eac2eb9c src/admin/web/ 0a5fff35555153f59d4346933030a67b6e1a8768cee7a47cfa2fcf1a2c564f63 src/admin/web/favicon.svg e0f0b302092ced1c84ef7e99864984444f0e9d4e3b7d85e74d3507d566952a7f src/admin/web/file-logs.js 85f54ce519140a38e31fb1b3d5974585748d7162f0499aa63703c1db56334b2c src/admin/web/host404.js -2fd6a462dc2d66d617052cbfffba24086809fa7b2650b17982180907f1b5a889 src/admin/web/index.html +31a45d496f39bec083a13b7ce68989cc3af25926aa313f4defb5ae09d87007da src/admin/web/index.html be9999a001c59630963d60539e860b59999dcf74c5ff0087b12a6fb69b4e7bd2 src/admin/web/integrations.js 7a12f020fc587205694978ab41b660e9a80487d413fbf6e34fc525eabc58308f src/admin/web/login-keys.json ac9f667273918e18406df06cb2613c923f50a88897693a03a18f500e22dc6ec2 src/admin/web/login.html @@ -329,8 +330,8 @@ b3239e67901f1796d7a974ade0796f2e3590ff8064628a5629b78c7f6ce2f32e src/admin/web/ 8c3da49973c62333559b0e3588c02beb0b425c025eac5cfa82a1bb968f70d9dd src/admin/web/vhosts/rates.js fafb4f9e8f123c93a5277052a375a9d2dd8f986322abd17f2206c16f0c37df06 src/admin/web/vhosts/render.js 90684f1bfb0e079438654e1f8c5b9ee1b4f74e49126a82c88768f3ae209a1875 src/admin/web/vhosts/routing.js -683b6506989d6ca9f3a0b1da7c1c931dce3ea3fbcb95dd9c56b038ac9a1c977c src/admin/web/web-server-profiles.js -f9854526ff1567de47ecb02af872bca6e13c0adb984ad5ef0c256e5fdbb3902e src/admin/web/web-server.js +b78d058deabc6a238560222bfdf131df3812407f73bdd000279df273b5d5dfc9 src/admin/web/web-server-profiles.js +c373850916ed66250583ebafa960e5c2a22ff3d0c63610ec61a1d16810bf5b17 src/admin/web/web-server.js 36f11beed56711640bb56bb6f452bf76dec2ce4be6a57e8abc19560af477c870 src/alerts.rs 2d40c2cb32d7365df0c9cd6c8cb6f0483c7a799786c648f4836a0d9740c6c5ef src/auth/files/mod.rs b2f948bcc3dbd24952c7b1b02d41d06757f49f0c38a78caf51f8f8a687d8480d src/auth/files/tests.rs @@ -360,7 +361,7 @@ ded4f445eec1caacd92fb1546f9eaeba1bc35fd164deb4d3142a64d0e9e261d9 src/balance/mo 5f9419176d5b927f8376d39b7dc4a6adf37b975835fedb35d82e7d6a2bb052fd src/balance/pool_selection.rs d789bf40cf9433e2fd16409d112210fe93154588b1ac9bddc9c7f78e1db14426 src/balance/pool_view.rs a361c341932ffd186c0b21356c91ab1fe8043f5020d40798266d15ae896a114e src/balance/tests.rs -ae06d238b1451328c751a511476ef39c012f3a397393f939ca02f96ecd0119a6 src/basic_auth/mod.rs +4cecc5ad1631179afc0c76bffe461fb75efe91f8366d99a58bc8c68f65d492c9 src/basic_auth/mod.rs 9a8858b7ff461a4d961ba701ca3ed6eaec15c3f7f05eef8e0e30edc63617605a src/basic_auth/tests.rs d9c44f9be9e3855c2339d4867c164b35938474b0a970de887d3990f33779b03b src/cache/cache_regression_tests.rs 7def03ace07dc38a4806277d75b6ce673d33ddaaf1c4855fa0a3372be1cf9489 src/cache/cold.rs @@ -419,8 +420,8 @@ a3bd297d160b3bad25bb362de848f182b7ec9807943c5c4537dafbc2a1e299d8 src/config/mod 75839458ddbc7480ec4492a95eeb67b617ba7d62f7b67e7a767a3453b74dbcbc src/config/route_policy_tests.rs caf688a85edc57e92d9ab0cd480282d4a3ecffe210473cf7e3abaccf8c8cd7ce src/config/routing.rs 4ba1998de8b8b7d43548d0a6708db59e05654c0ed5a999152885668246bd69d7 src/config/routing_conditions_tests.rs -29bdb73b679cf45ae0833b9b13ea86923690397c1a7a17c0ce364bc182bb2801 src/config/snapshot.rs -e79c79ffb6b8db04bf0e7581b217d3fd2cd88f23fc2b7e3874dca0eef19423bb src/config/tests.rs +fa835ba4bf063c373defd95e7b37e95d8a281cfa8b8595f4c1fc0cf3988af3a5 src/config/snapshot.rs +c56f696db4e37f5bbf7179e9a952aca8a89c81b4e479f9c79bb18a6f89cf5364 src/config/tests.rs f35de0ee1516ece6bbfd2b2a7db7d1e0f5048b0ec47cf2a3765dffb799abfd93 src/config/transport_tests.rs a09f361d70510d6226f4dd6785e649c3dc01ccafc70a4c8b0dcd098e224129b7 src/db.rs c290d0cb02dfa5d2c60ecabac1cfb20c8884e3d14cca1944906c6d8e677f1784 src/db/api_tokens.rs @@ -519,7 +520,7 @@ ab27174e36fabe0b4e610a96be4a81de4b9d173ec60736ce5d6b51c1a8fa9826 src/proxy/forw 8beccb28fbee2a7d7df5991ce93a8610f7d92bd1d4abed8679b968861ebd8a1f src/proxy/forward/success_prepare.rs a91d0bdc5740beec921df50ad14a4e85de0a73d46c9626c9cfd37a7f8baca317 src/proxy/forward/upstream.rs 03961ad0d386759ca2016d2dde37e124453514650d19a7feeaaa931f1ba81fc8 src/proxy/forward/vcl_policy_matrix_tests.rs -ca4b59cee7eefaedcdb30f3b60ea982b9f4e1df6cf03b7580bd4a53bcbf18ca4 src/proxy/forward/web_source.rs +05c2f6762b96d72159704bcf67d22dd0242479244027da20ec4b339d9b0e5cc3 src/proxy/forward/web_source.rs 3df1cd933c77e5390066e0bf3a4671a053b97ec1948c4a4204004312a3572c9d src/proxy/forward_entry.rs 9b25f5e3ea4443a63ee6f45d12e1957dd316fe8e85325fc00ea416faaab1025a src/proxy/h2_graceful.rs fc61c3f81d0bd8d91dab2a72267d497404e45e10e5cfc6000af16a254f888148 src/proxy/headers/authority_tests.rs @@ -534,7 +535,7 @@ a57ea795430bf52d550083fef759c739f3821217aac465c0024aa1565b0727d1 src/proxy/requ 16f9ed2ff51879095e6f1a818b03a76a03072b4c8c30d55201cb3d8bf229bf1d src/proxy/types.rs 15df425be6c7ad379920399e9f4674e126668157d64c67f5055a2b7931d8dc48 src/proxy/upstream_helpers.rs 02b56b5a7133e08ab47c9da0fdf1a807d054b2ff95efa0936a0c1d690474ce87 src/proxy/web_cache_revalidation/mod.rs -5522456cc85948228250feac92308d53b130c4a7af98d24f669aca4dfe6999b6 src/proxy/web_cache_revalidation/tests.rs +22c715aeb5b41eded4dc285a352ebf9ff8875f1342d72c1bfaf54131d3317f1a src/proxy/web_cache_revalidation/tests.rs 3d591201595a3b1e928ded20a8736477a47e5acc3bcbde158f7c17547ce155ba src/proxy/websocket.rs aa58bacc35458ac615680e774a235191f80abf0db978b68095571fce94c2b502 src/proxy/websocket/handshake.rs 02eae55007334a289c974c0a050ebe9360822574e5982950245a18e1af05a9fc src/proxy/websocket/http2_tests.rs @@ -627,21 +628,21 @@ fc8af7342a3b147921e9040116af5dfe680b3df910db2416ada18198bbeea7df src/vhost/redi 5a5768740e9a486436f6bb4e285ed99fd445cabbc21f317a47dc32c1f7091385 src/vhost/tests.rs 34ffb202075c9fa720d2a23c6d901471655befe583a6335d778391d467cc8186 src/vhost/validation.rs 8d1eff4b24f01d137414ef5419f75dd281879228adb70409645b11b3c78c20e9 src/web_server/config.rs -9744e8c29ae72a4d9fbc9a76166a97f8292c4c312295ea40d1cb699e03d80a9d src/web_server/config/compile.rs -5ed79fa5b9c53f95ca200d89a9ba927dda816b61fbdf3b852bd3c9670e3d2d4f src/web_server/config/model.rs -a863ad1337fbc353c0f42caea4ac8b3644792e2aa08c37f992b7882b4b8dc6d5 src/web_server/config/validation.rs +21b7872f9672d3a95647496977ca7c5dcde4c4c90d2f5f17260abf17ad24945b src/web_server/config/compile.rs +a4d394582f34ab16bb046780d4f755c6bbcc6afb497b03e277980750ab2e5f25 src/web_server/config/model.rs +9a3056d371219b7327d612b40b89587a0c30c7f8487386ba95e69050d0bdf11f src/web_server/config/validation.rs 86c744216d7132d8294a6e90ba9be5fd871646006313d1c62506d40c81db9b12 src/web_server/fastcgi.rs -54aa2dc94df97faabd4859a9dafe6a7cb1ba3337bfef5fa51a4432097a985d88 src/web_server/fastcgi/protocol.rs -fbaf972f9dd2842ec7df2878f0105c9ef4a877817f037f2332c4d5baabf2ead9 src/web_server/fastcgi/response.rs +d15716d8fa0d722e3189367fd395cac71c2f2a178335120a74a01696abc7cc04 src/web_server/fastcgi/protocol.rs +6b24c3ed2249e7c0d29ab27a5bc8ea05527a2a0314ae067acd6035327db3e814 src/web_server/fastcgi/response.rs 92d2ab4d7ecb766bbc705f8eba94c1ca33347ffb84b36e0ad0eccfed5915473f src/web_server/filesystem.rs d4fec3682532b0f2d11a0aefcd024f69fb623a39922ddb6c528a2d2de265347d src/web_server/htaccess.rs -b4646f705e532f682d6152b6827cc7f4f915766ebcb4af89eba9950965673772 src/web_server/htaccess/model.rs -a484113f2c1fea4e98a437acd8a28be6490d7e612f160a8728ceeaadd363f8ee src/web_server/htaccess/parse.rs -6e58e2674940bb0284035856fe9299a0555fee4c566de75e174deb373c3b164f src/web_server/htaccess/rewrite.rs +0b5060ea681bc35085511658d0d92d276aa39aa5c44cbab8b2adbdad84a05b8e src/web_server/htaccess/model.rs +2f8b33e736a49f5518360bf2be433dfdb0641eb00474da83cf7f2d255d6184d5 src/web_server/htaccess/parse.rs +8dce3855a191fea50962cd7e1132335e422047c9c41e7f5e1b3b023e25675131 src/web_server/htaccess/rewrite.rs 8ca74d9cc4470045301f70eb4a9fbabd0dbfe74434429148d2230df9f996c06c src/web_server/htaccess/tests.rs 7fe32af33b4d8e079ad724665aa1cfb62f6e98b9406b77168feaac55dac36137 src/web_server/metrics.rs -0f74d1fad9bc20a5f2ea1753381459c072cd8068cb13e7dfbc74e33eb3ace593 src/web_server/mod.rs -e9ba6e09ba2c8f8a33410c219d5ea29214cc53e279a43b17c110d24f17a5a71d src/web_server/request.rs +ee29a033d138001b9c304f28dbdf079031e58a0fd29d59c1834107be52a5fdbf src/web_server/mod.rs +f27e483737d17c73200b227b2720bfd79333bfd6abbe34ed9f73906f373a8a4e src/web_server/request.rs d98c80663847d6d83073df074ebff65952755415574708abcc153bd8d3adfaa9 src/web_server/response.rs b38a1c9e648e3606a534ebdf74f6315863a326c6de1ca8edc433abe9c1fed7b4 src/web_server/response/file.rs df87b67c75bbe58d7e077ed4c4cfa105ec680e89dd0c25af7dbd793d418a01ad src/web_server/response/file_body/mod.rs @@ -649,8 +650,8 @@ e5f5fbe702f66bfcbcbc1d1f3cd3d89bdbb929bb86aed94868a2a06a4b9e59e3 src/web_server 7da903c1a69be0ae6b85772b3208c518679efa8ed9d3e98adb694483518156b6 src/web_server/response/headers.rs 2665d4eac9a6430d68224874784cb65d9b9d424353af77735caf044401d08cb4 src/web_server/routing.rs 9e584eb4455a18641c2c89f9e9725745c93f32877abf0f0f2fbea9e3d5ef38c3 src/web_server/security.rs -b791762b4ab7a43c3be19df84e523faf3dfb4df055f66d02178f93edb60d2204 src/web_server/serve.rs -714418c86ab241020a561fcf662a8fe324a6a70cc2fd3a313c56d7939c14b9e8 src/web_server/tests.rs +42937064cd38468b0c2e2f57b810bee9df9e6568e74d1ab3d805ea9a39259375 src/web_server/serve.rs +951291172a80ab57205aa10dd95e2805d0afc82f86e3c46479c96962a3853c92 src/web_server/tests.rs f00743af2cf4a5952caef7a1dcf68e7817b5599a252a9973e1c22045517c0b0e tests/fixtures/argon2id.json 9540e9a904455a2190c2d0a32b47b1345976e4c4618767ed2b55898d13da9987 tests/fixtures/balance_rendezvous_vectors.txt affb5c728d2d2bd58807c080f22ac17575e06486c7cca38dc13cf58ad01873ae tests/fixtures/routing_conditions_cases.json diff --git a/docs/CUSTOM_LOCATIONS.md b/docs/CUSTOM_LOCATIONS.md index 86b8c46..6eb7192 100644 --- a/docs/CUSTOM_LOCATIONS.md +++ b/docs/CUSTOM_LOCATIONS.md @@ -93,4 +93,4 @@ If all you need is a different error **page body**, use **Vhost → Pages → In ## Not an Nginx configuration parser -The editor does not run arbitrary Nginx snippets, filesystem aliases, arbitrary `if` rules or per-location static roots. Configure static paths in a reusable Web Service, then assign that service to the location. Inspect [Vhosts](VHOSTS.md) and [Access](ACCESS.md) for the policies applied before connecting to the backend. +The editor does not run arbitrary Nginx snippets, filesystem aliases, arbitrary `if` rules or per-location static roots. Configure static paths in a reusable Web Service, then assign that service to the location. For PHP, CGI and other FastCGI scripts, mount a dedicated Web Service with its own document root, backend socket, extensions and public `SCRIPT_NAME` prefix; see [FastCGI / CGI](FASTCGI.md). Inspect [Vhosts](VHOSTS.md) and [Access](ACCESS.md) for the policies applied before connecting to the backend. diff --git a/docs/FASTCGI.md b/docs/FASTCGI.md new file mode 100644 index 0000000..b0acb0e --- /dev/null +++ b/docs/FASTCGI.md @@ -0,0 +1,110 @@ +# FastCGI and CGI applications in the Web Server + +RustProxy 0.42.2 can serve executable application scripts through **existing external FastCGI backends**. It does not embed PHP, execute scripts in the RustProxy process, start a CGI worker, or parse Nginx/Angie configuration files. The routing and application settings are generic: they work with PHP sites, CGI control panels, monitoring tools, custom FastCGI applications, and other programs using compatible FastCGI responders. + +## Supported backends + +Select **Web Server → Web Service → PHP-FPM / FastCGI → Handler** (or edit a shared profile). The persisted field is `php.handler` for backwards compatibility; older `php` configurations still default to `php_fpm`. + +| Handler (`php.handler`) | Use | Example `php.endpoint` | Example `php.extensions` | +|---|---|---|---| +| `php_fpm` | Existing PHP-FPM pool | `unix:/run/php/site.sock` | `php`, `phtml` | +| `fcgiwrap` | Existing CGI scripts executed by a separately running **fcgiwrap** service | `unix:/run/fcgiwrap.socket` | `cgi`, `pl` | +| `fastcgi` | Other compatible FastCGI responders (no CGI process launcher built into RustProxy) | `tcp:127.0.0.1:9001` | `fcgi` | + +All handlers support Unix sockets (`unix:/absolute/path.sock`) and local TCP (`tcp:127.0.0.1:port` or `tcp:[::1]:port`). TCP is deliberately restricted to loopback. FastCGI must **not** be exposed on a public interface. The backend process must already be running, and the RustProxy service account must be able to connect to its socket. The configured `php.extensions` determine which *existing files* are executable; everything else follows static-file policy, except that a `fcgiwrap` Web Service deliberately refuses to serve ordinary files and directory listings to avoid leaking CGI source or adjacent configuration. PHP extensions can only be assigned to `php_fpm`; `PHP_VALUE` and `PHP_ADMIN_VALUE` are PHP-FPM-only. + +The existing **PHP-FPM profiles** section also stores the new handler choices without changing existing profile IDs. Create a separate Web Service/profile for different document roots, handler types, sockets, or trust boundaries. Each Web Service has one FastCGI handler; combine several services under one domain with **Vhost → Custom locations** rather than attempting to paste Nginx `location` or `fastcgi_pass` directives. + +## How paths are mapped + +When a request is routed to a Web Service, RustProxy resolves the effective path **inside that service's `document_root`**. The path is validated and the script must exist as a regular file; symlinks are disallowed for FastCGI script execution. The FastCGI request contains: + +| Parameter | Source and behavior | +|---|---| +| `SCRIPT_FILENAME` | Canonical Web Service document root plus the validated effective script path; never taken from an HTTP header or arbitrary custom FastCGI parameter. | +| `SCRIPT_NAME` | `php.script_name_prefix` + effective script path. Leave the prefix empty for normal mounts. Set it to the public URL prefix stripped/replaced by the Vhost location, such as `/portal/cgi-bin`. | +| `REQUEST_URI` | Original public path and query, for example `/portal/cgi-bin/status.cgi?view=1`. | +| `QUERY_STRING` / `REQUEST_METHOD` | Request query / method. Request bodies are streamed to FastCGI. | +| `PATH_INFO` | Optional remaining `/path/info` after the existing script filename, when `php.path_info=true`. | +| `REMOTE_ADDR` / `REMOTE_PORT` | Validated request client address / port. | +| `REMOTE_USER` / `AUTH_USER` | Only set when **Vhost Basic Auth** successfully authenticated the user; never copied from an unverified `REMOTE_USER` header. | +| `HTTP_AUTHORIZATION` | Forwarded only when authorized by Vhost credential-forwarding settings and `php.pass_authorization`; disable when not needed. | +| `HTTP_*` | Selected incoming headers, with hop-by-hop/unsafe headers removed. | + +Custom FastCGI parameters (`php.custom_params`) are bounded static `NAME = value` pairs. Core CGI, identity, PHP control and `HTTP_*` parameters are **reserved** to avoid spoofing `SCRIPT_FILENAME`, `REMOTE_USER` and other security-sensitive values. Dynamic Nginx expressions (`$1`, `$remote_user`, `$http_authorization`) are **not** evaluated in custom parameters; equivalent core variables are generated by RustProxy. For private per-site values, prefer backend environment configuration over secrets in the RustProxy JSON configuration. + +## Generic example: static assets, PHP and executable CGI on one HTTPS domain + +Suppose an application is exposed as `https://portal.example.test/console/` with these filesystem paths and processes: + +```text +/srv/apps/console/public/ # index.html, assets, PHP scripts +/srv/apps/console/cgi-bin/ # executable *.cgi scripts +unix:/run/php/console.sock # existing PHP-FPM pool +unix:/run/fcgiwrap.socket # existing fcgiwrap worker +``` + +Create **three reusable Web Services** (one safe default, one PHP/static application root and one isolated CGI root): + +| Service ID | Document root | Handler | Extensions | Public `SCRIPT_NAME` prefix | +|---|---|---|---|---| +| `empty-default` | `/srv/www/empty` (empty directory) | Disabled | — | — | +| `console-web` | `/srv/apps/console/public` | `php_fpm`, endpoint `unix:/run/php/console.sock` | `php` | `/console` | +| `console-cgi` | `/srv/apps/console/cgi-bin` | `fcgiwrap`, endpoint `unix:/run/fcgiwrap.socket` | `cgi` | `/console/cgi-bin` | + +For PHP/CGI services, enable FastCGI and set `symlink_policy=deny`. The PHP Web Service safely serves regular static files **and** invokes PHP-FPM for `.php`, including `index.php`. Set `console-web.index` to `index.php, index.html` and adjust `try_files` to the application's needs. Keep non-executable files out of the CGI root; use filesystem permissions and socket ownership to isolate each runtime. Enable `path_info` only if `/script.php/extra` or `/script.cgi/extra` is needed. + +Create a **Vhost** bound to the HTTP and HTTPS listeners, select the appropriate certificate (RustProxy ACME or an imported certificate), enable **Force HTTPS** (and HTTP/2 if desired), and choose `empty-default` as the default Web Server source to avoid unintentionally exposing the application at unprefixed `/index.php` paths. Add these **Custom locations** (keep the CGI regex rule ahead of the fallback prefix rule): + +| Match type | Path/pattern | Source | Path rewrite mode and value | +|---|---|---|---| +| `regex` | `^/console/cgi-bin/(.*\.cgi(?:/.*)?)$` | `console-cgi` | `regex` → `/$1` | +| `prefix` | `/console/` | `console-web` | `strip_prefix` | +| `exact` | `/` | Redirect to `/console/` (302) | Not applicable | +| `exact` | `/console` | Redirect to `/console/` (301) | Not applicable | + +The exact and regex rules use Rust's `regex` syntax, not PCRE look-arounds. `strip_prefix` and `regex` rewrite values remove the public path prefix while preserving script names. For example, `GET /console/cgi-bin/health.cgi?x=1` is processed by `console-cgi` as `/health.cgi` with `SCRIPT_FILENAME=/srv/apps/console/cgi-bin/health.cgi`, `SCRIPT_NAME=/console/cgi-bin/health.cgi` and `REQUEST_URI=/console/cgi-bin/health.cgi?x=1`. Likewise, `GET /console/index.php` or `GET /console/` (with `index.php` configured) is executed by `console-web` through PHP-FPM; `/console/assets/style.css` is served statically from that same service. An additional regex PHP location can be configured if PHP scripts need a **different** root or socket; otherwise a separate PHP regex location is unnecessary. You may also replace `console-cgi` with a `fastcgi` responder service for a compatible standalone application. + +**Protect access:** Enable **Vhost Basic Auth** if the application needs it, using the existing RustProxy credential settings (or another supported authentication provider; only verified Vhost Basic Auth currently maps to `REMOTE_USER`). Avoid publishing admin/CGI directories as static paths. `deny all` for hidden files can be implemented with Vhost ACL/location rules and optional `.htaccess` security rules. Server-level HTTPS, certificate renewal, IPv6 listeners and access/error logging are configured through RustProxy listeners/Vhosts/logs, not inside FastCGI settings. + +## Migrating from Nginx / Angie + +| Original directive | RustProxy equivalent | +|---|---| +| `listen 80` / `listen 443 ssl` / `http2 on` | Named HTTP / HTTPS listeners, HTTPS Vhost selection, HTTP/2 setting | +| `return 302 https://$host$request_uri` | Force HTTPS (RustProxy's configured HTTPS redirect status/semantics may differ from 302) | +| `server_name` | Vhost hostnames | +| `acme` / `$acme_cert_*` | Certificates → ACME certificate and Vhost certificate selection; not Angie variable import | +| `access_log` / `error_log` | RustProxy logs and monitoring settings | +| `auth_basic` / `auth_basic_user_file` | Vhost Basic Auth / credential management, not direct use of Angie `auth_basic_user_file` lines | +| `location =` with `return` | Exact Custom location with Redirect | +| `location /prefix/` / `alias` | Web Service `document_root` plus Custom location `strip_prefix` | +| `location ~ regex` / `rewrite ... break` | Regex Custom location with regex path rewrite | +| `include fastcgi_params` / `include fastcgi-php.conf` | RustProxy generates CGI/FastCGI core parameters; no Nginx `include` parser | +| `fastcgi_pass` | Web Service FastCGI endpoint: Unix or loopback TCP | +| `fastcgi_param SCRIPT_FILENAME` / `SCRIPT_NAME` | Document root, optional URL prefix, location rewrite; do **not** override with untrusted variables | +| `fastcgi_param REMOTE_USER`, `AUTH_USER` | Verified Vhost Basic Auth identity (when available) | +| `location ~ /\.` + `deny all` | Web Service hardening and explicit restrictive ACL/location rules | + +**Not a full Nginx/Angie interpreter.** RustProxy does not accept raw `server { ... }` files, Nginx `include`, arbitrary runtime `fastcgi_param` expressions, or arbitrary system-level PHP/CGI process management. Translate the routing and authentication rules into the panel/API as above. Full location, rewrite and authentication behavior is documented in [Custom locations](CUSTOM_LOCATIONS.md), [Vhosts](VHOSTS.md) and [Access](ACCESS.md). + +## Verification and troubleshooting + +```bash +# Check HTTP -> HTTPS and the application's protected/redirect paths: +curl -I http://portal.example.test/console/ +curl -Ik https://portal.example.test/console/ +# Use appropriate test credentials, if Basic Auth is enabled: +curl -ik -u operator https://portal.example.test/console/cgi-bin/health.cgi +# Direct non-executable file requests under a CGI-only root must be forbidden: +curl -Ik https://portal.example.test/console/cgi-bin/config.txt +``` + +- **502 / 504:** inspect the external process, socket permissions, FastCGI stderr (bounded in logs) and timeouts. A Unix socket name alone does not start `fcgiwrap` or PHP-FPM. +- **403:** check route-to-Web-Service selection, file visibility, symlink policy, script extension allowlist, Vhost authentication and `.htaccess` protection. A CGI-only root intentionally returns 403 for non-executable files. +- **404:** verify regex location captures, replacement path, actual file under `document_root`, `index` and `try_files` (note that `try_files` candidates are evaluated inside the selected Web Service). +- **Incorrect `SCRIPT_NAME` / missing authentication identity:** confirm the public `script_name_prefix`, whether the Vhost location strips/replaces the prefix, Basic Auth success and forwarding settings. +- **Browser downloads a script:** verify the active Web Service and extension. RustProxy refuses to send known executable script extensions as static files when no matching handler is configured. + +The new protocol paths are covered by source-level tests using a mock FastCGI responder. Before production use, run `./dev.sh check` and `./dev.sh test` with the project toolchain and exercise real PHP-FPM and fcgiwrap instances; mock responders cannot prove OS-level script execution. diff --git a/docs/FEATURES.md b/docs/FEATURES.md index c5dbe15..73dcdc7 100644 --- a/docs/FEATURES.md +++ b/docs/FEATURES.md @@ -35,7 +35,7 @@ RustProxy is a single service that combines a reverse proxy, a static/PHP web se - `try_files`, regex rewrites and a safe subset of Apache `.htaccess` rules. - Conditional requests (`ETag`, `Last-Modified`), byte ranges, precompressed `.br`/`.gz` sidecars and optional Linux `sendfile`. - Symlink policy, attack-probe blocking and header hardening presets. -- PHP through external PHP-FPM with shared profiles, per-application pools and resource limits. +- External FastCGI: PHP-FPM pools, CGI scripts via fcgiwrap, and generic FastCGI responders; Unix or loopback TCP endpoints, script allowlists, SCRIPT_NAME mount prefixes, PATH_INFO, bounded request/resource limits, Vhost location routing and shared profiles. - Presets for single-page apps, WordPress and Roundcube. ![Web Server editor](images/web-server.png) diff --git a/docs/PHP_FPM.md b/docs/PHP_FPM.md index 8a0e429..04872d8 100644 --- a/docs/PHP_FPM.md +++ b/docs/PHP_FPM.md @@ -1,6 +1,6 @@ # PHP-FPM with Web Services -RustProxy's Web Server supports **FastCGI** forwarding to an existing **PHP-FPM** pool for configured script extensions. RustProxy does not include a PHP interpreter or run the PHP application itself. +RustProxy's Web Server supports **FastCGI** forwarding to an existing **PHP-FPM** pool for configured script extensions. For non-PHP CGI programs, fcgiwrap and other FastCGI responders, see the general [FastCGI guide](FASTCGI.md). RustProxy does not include a PHP interpreter or run the PHP application itself. ## Before enabling PHP diff --git a/docs/README.md b/docs/README.md index b38c708..c6532b0 100644 --- a/docs/README.md +++ b/docs/README.md @@ -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. +- [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. - [TCP/UDP Streams](STREAMS.md) — non-HTTP forwarding. diff --git a/docs/WEB_SERVER.md b/docs/WEB_SERVER.md index c86fd49..1d46e9b 100644 --- a/docs/WEB_SERVER.md +++ b/docs/WEB_SERVER.md @@ -1,13 +1,13 @@ # Web Server — static sites, downloads and routing -The built-in Web Server serves local files and, optionally, passes PHP scripts to an **external PHP-FPM service**. A reusable **Web Service** is referenced by a Vhost or by a Custom location. Its files and PHP settings are not duplicated in the Vhost. +The built-in Web Server serves local files and can forward executable scripts to **external PHP-FPM, fcgiwrap or generic FastCGI responders**. A reusable **Web Service** is referenced by a Vhost or by a Custom location. Its files and PHP settings are not duplicated in the Vhost. ## Create a Web Service 1. Open **Web Server → New Web Service**. Choose an ID/name and an absolute document root readable by the RustProxy service account. 2. Set index files (default `index.html`, `index.htm`), whether directory listing is allowed (off by default), MIME handling and download extensions. 3. Add `try_files`, rewrites and response headers only if your application requires them. VCL-style cache rules (including `pass` / `cookie_pass`) are **not** evaluated for Web Server sources; the static-extension Cookie option and the regular cache policy still apply to local files. -4. Enable PHP only if you have a reachable, protected PHP-FPM endpoint; otherwise static files do not need any PHP runtime. +4. Enable FastCGI only if you have a reachable, protected external PHP-FPM pool, CGI runner or compatible FastCGI responder; otherwise static files do not need an executable runtime. 5. Save, create or edit a **Vhost**, select **Web Server** as source and choose the service ID. 6. Test index files, static assets, missing files, direct directory access, downloads and headers. @@ -57,13 +57,17 @@ The editor supports common website presets to fill suggested fields; review thei An optional bounded Apache-style `.htaccess` compatibility layer supports a **subset** of rules useful for migrations, not arbitrary Apache modules or dynamic directive execution. It can scan configured paths and enforce stricter handling of unsupported expressions. Prefer explicit `try_files`/rewrite/header controls when possible and test migrated sites. A real Apache configuration cannot be pasted unchanged into RustProxy. +With **Strict unsupported-directive mode disabled**, harmless unimplemented directives (such as `ErrorDocument` and unsupported `Options` tokens) are skipped and logged as warnings during Web Service validation/apply; inspect the server logs or expand **Skipped .htaccess directives** on the Web Service card for file/line locations. They do **not** become active Apache functionality. Unsupported security/handler syntax is still rejected to avoid unintentionally exposing protected content. + +For common Apache 2.2 migrations, `Order deny,allow`, `Order allow,deny`, `Order mutual-failure`, `Allow from all` / `Deny from all`, and `Allow from` / `Deny from` explicit IP addresses or CIDR networks (IPv4/IPv6) are supported and **enforced** using the actual client IP. For instance, `Deny from all` blocks the affected directory, returning HTTP 403; it is not silently ignored. `Order allow,deny` denies unmatched clients by default, while `Order deny,allow` allows them by default. Hostname-based ACLs and other unsupported access/authentication constructs fail validation even with Strict disabled. Test allow/deny cases after migrating; legacy access rules are not a general Apache authorization emulator. + ## Admin editor layout In **Web Server → Edit → Delivery**, static file delivery, dynamic compression and precompressed assets have separate sections. In **PHP-FPM**, profile/endpoint, request options, resource limits and FastCGI/php.ini overrides are grouped. Disabled local controls indicate that PHP is off or a shared profile owns those settings; selection and saved values behave as before. -## PHP and error responses +## FastCGI and error responses -A Web Service may enable PHP via a shared PHP-FPM profile or its own configuration. PHP is executed by the FPM service, not RustProxy, and must not be exposed as a raw Internet port. Use dedicated pools for different applications. See [PHP-FPM](PHP_FPM.md). +A Web Service may use external PHP-FPM, fcgiwrap or another FastCGI responder via its local settings or an existing shared profile. RustProxy does not execute scripts itself. Combine multiple Web Services (distinct document roots, extensions and endpoints) using Vhost Custom locations; see the generic [FastCGI guide](FASTCGI.md). Existing PHP-FPM pool isolation rules continue to apply; see [PHP-FPM](PHP_FPM.md). Missing static files return **HTTP 404 Not Found**, unreadable/blocked paths **403 Forbidden**, unsupported static methods **405 Method Not Allowed** (with `Allow: GET, HEAD`), and internal failures **500 Internal Server Error**. The built-in Web Server now uses the existing **application-style HTML error pages** for statuses with a bundled template (including 400, 403, 404, 500 and PHP-FPM gateway errors). Other generated error statuses, such as 405, use the shared styled HTML fallback. The regular built-in 502 is styled with RustProxy branding; auth-specific Tinyauth failure pages have their own wording and are served before any origin application is accessed. Neither internal filesystem paths nor `RustProxy: Web Server ...` diagnostics are included in the public body. Details for 5xx filesystem failures remain in server logs. diff --git a/langs/en_US.json b/langs/en_US.json index e6bbcd5..193c81f 100644 --- a/langs/en_US.json +++ b/langs/en_US.json @@ -2079,7 +2079,7 @@ "webServiceTabMime": "MIME", "webServiceTabCacheHeaders": "Cache & headers", "webServiceTabDelivery": "Delivery", - "webServiceTabPhp": "PHP-FPM", + "webServiceTabPhp": "FastCGI / PHP", "webServiceTabSecurity": "Security", "webServiceId": "Service ID", "webServiceName": "Name", @@ -2135,7 +2135,7 @@ "webServicePhpValuesInvalid": "PHP INI overrides must use one unique directive = value entry per line.", "webServicePhpDocsButton": "FastCGI syntax and safety", "webServicePhpDocsTitle": "PHP-FPM / FastCGI configuration", - "webServicePhpDocsIntro": "RustProxy connects directly to an existing PHP-FPM pool. Prefer a Unix socket on the same host. TCP is accepted only on loopback and is not a public/network FastCGI transport.", + "webServicePhpDocsIntro": "RustProxy connects to existing PHP-FPM pools, CGI runners such as fcgiwrap, or compatible FastCGI responders. Use a trusted Unix socket or a loopback-only TCP endpoint; never expose a FastCGI socket publicly.", "webServicePhpDocsEndpointTitle": "Endpoint syntax", "webServicePhpDocsEndpoint": "Use unix: plus full socket path, or tcp: plus a literal loopback IP and port. TCP hostnames/public addresses are rejected. Use distinct FPM sockets for applications with different PHP INI restrictions.", "webServicePhpDocsCustomTitle": "Custom FastCGI parameters", @@ -2144,9 +2144,9 @@ "webServicePhpDocsValues": "These lines go into PHP_VALUE. Use the separate PHP_ADMIN_VALUE field for trusted administrative settings; neither one isolates workers sharing the same PHP-FPM pool.", "webServicePhpDocsLimitsTitle": "Limits and headers", "webServicePhpDocsLimits": "Request timeout covers the FastCGI exchange. The body limit is enforced while streaming and returns 413 when exceeded; 0 disables the RustProxy-side body limit. Response-header and stderr limits bound memory/diagnostic data. Up to 64 custom FastCGI parameters and 64 PHP INI overrides are accepted, with at most 128 KiB of combined custom data. Authorization forwarding can be disabled for applications that do not need HTTP_AUTHORIZATION.", - "webServicePhpDocsSecurity": "Do not put secrets in custom parameters or PHP_VALUE unless you accept storing them in normal Web Service configuration. Use a dedicated non-root PHP-FPM pool identity and keep PHP-FPM off public networks.", - "webServicePhpHelp": "RustProxy speaks FastCGI directly to a long-running PHP-FPM pool. PHP is not spawned per request and PHP source is never served when PHP handling is selected.", - "webServicePhpSymlinkConflict": "PHP-FPM currently requires the symlink policy to be Deny.", + "webServicePhpDocsSecurity": "A CGI runner executes local scripts with its own OS identity. Restrict socket access and script filesystem permissions; use separate Web Services for different script roots or handlers. Protect the public Vhost with authentication and access rules where necessary. Avoid storing secrets in plain FastCGI parameter overrides.", + "webServicePhpHelp": "RustProxy forwards configured script extensions to an existing FastCGI responder: PHP-FPM, fcgiwrap or another compatible backend. It does not start processes.", + "webServicePhpSymlinkConflict": "FastCGI script execution requires symlink policy Deny.", "webServiceSymlinkPolicy": "Symlink policy", "webServiceSymlinkDeny": "Deny", "webServiceSymlinkInsideRoot": "Allow only inside document root (Linux)", @@ -2227,6 +2227,8 @@ "webServiceHtaccessRecursive": "Scan subdirectories", "webServiceHtaccessStrict": "Strict unsupported-directive mode", "webServiceHtaccessDocs": "Compatibility documentation", + "webServiceHtaccessWarningsCount": "Skipped .htaccess directives (ignored)", + "webServiceHtaccessStrictHelp": "With Strict off, unsupported non-security directives are skipped and logged as warnings. Order/Allow/Deny with all, IP or CIDR are enforced; unsupported access rules still block Apply.", "webServiceHtaccessHelp": "RustProxy compiles a bounded Apache-compatible subset when the Web Service is applied. Files are not parsed on every request; apply the Web Service again after editing .htaccess on disk.", "webServiceHtaccessDocsTitle": ".htaccess compatibility", "webServiceHtaccessDocsIntro": "This is a migration-oriented compatibility layer, not a complete Apache runtime. Supported directives are compiled into RustProxy Web Server rules.", @@ -2238,7 +2240,7 @@ "webServiceHtaccessDocsReloadTitle": "Loading and limits", "webServiceHtaccessDocsReload": "Files are read and compiled on Validate, save and apply. RustProxy does not parse .htaccess per request. Re-apply after changing a file. The scan is bounded to 128 files, depth 16, 128 KiB per file and 1 MiB total.", "webServiceHtaccessDocsUnsupportedTitle": "Not Apache-complete", - "webServiceHtaccessDocsUnsupported": "ErrorDocument, SetEnvIf, Redirect/RedirectMatch and FallbackResource are not implemented in this compatibility layer. General Files/FilesMatch, unsupported authentication/authorization directives, non-PHP handlers and SetHandler are rejected even when Strict mode is off because silently ignoring them could weaken access control or expose source. .htaccess/.htpasswd files are always blocked from HTTP delivery. Other unsupported non-security directives are logged and ignored unless Strict mode is enabled.", + "webServiceHtaccessDocsUnsupported": "ErrorDocument, SetEnvIf, Redirect/RedirectMatch and FallbackResource are not implemented. Order/Allow/Deny with all, IP or CIDR (IPv4/IPv6) are supported and enforced. General Files/FilesMatch, unsupported authentication/authorization and hostname access directives, non-PHP handlers and SetHandler are rejected even with Strict off: ignoring them could expose protected content. .htaccess/.htpasswd are never served over HTTP. Other unsupported non-security directives are logged and skipped with Strict off.", "webServiceHtaccessDocsSecurity": "Vhost/location ACL, authentication, error pages and response rules still remain authoritative. .htaccess cannot escape the document root, select an arbitrary FastCGI socket or override protected framing headers.", "webServicePresetTitle": "Configuration preset", "webServicePreset": "Preset", @@ -2618,13 +2620,13 @@ "locationErrorFallbackTarget": "Error fallback target", "locationErrorFallbackStatuses": "Intercepted status codes", "locationErrorFallbackHelp": "Optional Nginx-style error fallback. Target an enabled internal location by ID. Supported statuses: 403, 404, 500, 502, 503, 504.", - "webServicePhpPathInfo": "Enable PHP PATH_INFO splitting", + "webServicePhpPathInfo": "Enable FastCGI PATH_INFO splitting", "phpProfileSelect": "PHP-FPM configuration", "phpProfileLocal": "Local configuration", - "phpProfileHelp": "Select a shared PHP-FPM profile or configure this Web Service directly. Shared edits affect all attached services.", - "phpProfileManage": "Manage PHP-FPM profiles", - "phpProfileToolbar": "PHP-FPM profiles", - "phpProfileTitle": "Shared PHP-FPM profiles", + "phpProfileHelp": "Select a shared FastCGI profile or configure this Web Service directly. Shared edits affect all attached services.", + "phpProfileManage": "Manage FastCGI profiles", + "phpProfileToolbar": "FastCGI profiles", + "phpProfileTitle": "Shared FastCGI profiles", "phpProfileDescription": "Expand a profile to edit it; save applies immediately to every attached Web Service.", "phpProfileAdd": "Add profile", "phpProfileNew": "New PHP-FPM profile", @@ -2645,10 +2647,10 @@ "backendHealthOverridesHelp": "When unchecked, inherit the vhost health policy. Disabling monitoring keeps the backend available for explicitly pinned locations, without active probes or passive ejection. Use a custom check for an individual backend.", "cacheOnlyHits": "Show RustProxy cache diagnostics only on HIT (retain origin headers)", "cacheDetailedStatus": "X-Cache shows STALE and REVALIDATED instead of HIT", - "phpHintEnabled": "Run configured PHP file extensions through an already-running PHP-FPM pool. RustProxy does not start PHP; non-PHP files remain static.", + "phpHintEnabled": "Enable execution of configured script extensions through an already-running PHP-FPM, CGI runner, or FastCGI responder. The backend must be reachable.", "phpHintPathInfo": "Split /static.php/skins/file.css into SCRIPT_FILENAME=static.php and PATH_INFO=/skins/file.css. Useful for Roundcube; usually unnecessary for WordPress. Off by default.", "phpHintPassAuthorization": "Pass the incoming Authorization header as HTTP_AUTHORIZATION to PHP (API/Bearer/Basic authentication). Disable if not needed.", - "phpHintExtensions": "Comma-separated extensions without leading dots: php, phtml. Only these extensions run as PHP.", + "phpHintExtensions": "Only these extensions are executed by the selected backend. Use php for PHP-FPM and cgi or fcgi for compatible script handlers. Unhandled script extensions are not served as static code.", "phpHintConnectTimeout": "PHP-FPM socket connection timeout in milliseconds: 1000 = 1 second. Range: 50–60000.", "phpHintRequestTimeout": "Timeout for the complete FastCGI request in milliseconds: 30000 = 30 seconds. Range: 100–3600000.", "phpHintConcurrency": "Maximum concurrent PHP requests per service: e.g. 64. Exhaustion returns 503. Range: 1–4096.", @@ -4434,6 +4436,10 @@ "vhJsonDraft": "Unapplied JSON edits", "vhJsonReloadConfirm": "Discard the unapplied JSON edits and reload the current form values?", "vhJsonInvalidAcl": "Use null or an ACL object with an allow/deny default and IP/CIDR rules.", - "vhJsonInvalidPaths": "Use an array of up to 64 location objects." + "vhJsonInvalidPaths": "Use an array of up to 64 location objects.", + "webServiceFastCgiHandler": "FastCGI handler", + "webServiceFastCgiHandlerHelp": "Choose a backend protocol responder: PHP-FPM executes PHP, fcgiwrap runs CGI programs, and FastCGI responder connects to any compatible application. Configure separate Web Services and Vhost locations for different roots or endpoints.", + "webServiceFastCgiScriptPrefix": "Public SCRIPT_NAME prefix", + "webServiceFastCgiScriptPrefixHelp": "When a Vhost location strips a URL mount prefix (for example /app/cgi-bin), set it here. RustProxy prepends it to SCRIPT_NAME but leaves SCRIPT_FILENAME under the document root." } -} \ No newline at end of file +} diff --git a/langs/pl_pl.json b/langs/pl_pl.json index 3e6d4b6..0a89b61 100644 --- a/langs/pl_pl.json +++ b/langs/pl_pl.json @@ -2079,7 +2079,7 @@ "webServiceTabMime": "MIME", "webServiceTabCacheHeaders": "Cache i nagłówki", "webServiceTabDelivery": "Serwowanie", - "webServiceTabPhp": "PHP-FPM", + "webServiceTabPhp": "FastCGI / PHP", "webServiceTabSecurity": "Bezpieczeństwo", "webServiceId": "ID usługi", "webServiceName": "Nazwa", @@ -2135,7 +2135,7 @@ "webServicePhpValuesInvalid": "Nadpisania PHP INI muszą mieć unikalny format dyrektywa = wartość, po jednym wpisie na linię.", "webServicePhpDocsButton": "Składnia i bezpieczeństwo FastCGI", "webServicePhpDocsTitle": "Konfiguracja PHP-FPM / FastCGI", - "webServicePhpDocsIntro": "RustProxy łączy się bezpośrednio z istniejącą pulą PHP-FPM. Na tym samym hoście preferuj socket Unix. TCP jest akceptowane wyłącznie na loopback i nie jest publicznym/sieciowym transportem FastCGI.", + "webServicePhpDocsIntro": "RustProxy łączy się z istniejącymi pulami PHP-FPM, wykonawcami CGI (np. fcgiwrap) lub innymi responderami FastCGI. Użyj chronionego socketu Unix albo lokalnego TCP; nie wystawiaj FastCGI publicznie.", "webServicePhpDocsEndpointTitle": "Składnia endpointu", "webServicePhpDocsEndpoint": "Użyj unix: z pełną ścieżką gniazda albo tcp: z adresem IP loopback i portem. Nazwy DNS i publiczne adresy TCP są zabronione. Oddziel pule PHP-FPM aplikacji z różnymi ograniczeniami INI.", "webServicePhpDocsCustomTitle": "Własne parametry FastCGI", @@ -2144,9 +2144,9 @@ "webServicePhpDocsValues": "Każda linia trafia do PHP_VALUE. Zaufane ustawienia administracyjne wpisuj osobno w PHP_ADMIN_VALUE; żadne z tych pól nie izoluje procesów korzystających z tej samej puli PHP-FPM.", "webServicePhpDocsLimitsTitle": "Limity i nagłówki", "webServicePhpDocsLimits": "Timeout żądania obejmuje wymianę FastCGI. Limit body jest egzekwowany podczas streamingu i po przekroczeniu zwraca 413; 0 wyłącza limit body po stronie RustProxy. Limity nagłówków odpowiedzi i stderr ograniczają pamięć/dane diagnostyczne. Dozwolone są maks. 64 własne parametry FastCGI i 64 nadpisania PHP INI, łącznie do 128 KiB danych własnych. Przekazywanie Authorization można wyłączyć, gdy aplikacja nie potrzebuje HTTP_AUTHORIZATION.", - "webServicePhpDocsSecurity": "Nie umieszczaj sekretów we własnych parametrach ani PHP_VALUE, jeśli nie akceptujesz ich przechowywania w zwykłej konfiguracji Web Service. Używaj osobnej, nieuprzywilejowanej tożsamości puli PHP-FPM i nie wystawiaj PHP-FPM do publicznej sieci.", - "webServicePhpHelp": "RustProxy komunikuje się bezpośrednio przez FastCGI z długowieczną pulą PHP-FPM. PHP nie jest uruchamiane osobno dla każdego żądania, a kod źródłowy PHP nie jest serwowany, gdy obsługa PHP jest wybrana.", - "webServicePhpSymlinkConflict": "PHP-FPM wymaga obecnie polityki symlinków Deny.", + "webServicePhpDocsSecurity": "Wykonawca CGI uruchamia lokalne skrypty ze swoimi uprawnieniami systemowymi. Ogranicz dostęp do socketu i katalogów, a dla różnych środowisk stosuj osobne Web Service. Gdy potrzeba, chroń Vhost autoryzacją i regułami dostępu. Nie zapisuj sekretów w jawnych parametrach FastCGI.", + "webServicePhpHelp": "RustProxy kieruje wybrane rozszerzenia skryptów do istniejącego serwera FastCGI: PHP-FPM, fcgiwrap lub innego zgodnego backendu. Nie uruchamia procesów.", + "webServicePhpSymlinkConflict": "Wykonywanie skryptów FastCGI wymaga polityki symlinków Deny.", "webServiceSymlinkPolicy": "Polityka symlinków", "webServiceSymlinkDeny": "Zabroń", "webServiceSymlinkInsideRoot": "Zezwól tylko wewnątrz document root (Linux)", @@ -2227,6 +2227,8 @@ "webServiceHtaccessRecursive": "Skanuj podkatalogi", "webServiceHtaccessStrict": "Tryb ścisły dla niewspieranych dyrektyw", "webServiceHtaccessDocs": "Dokumentacja zgodności", + "webServiceHtaccessWarningsCount": "Pominięte dyrektywy .htaccess (ostrzeżenia)", + "webServiceHtaccessStrictHelp": "Po wyłączeniu trybu ścisłego nieobsługiwane dyrektywy niezwiązane z bezpieczeństwem są pomijane, a ostrzeżenia trafiają do logów. Order/Allow/Deny z all, IP lub CIDR są egzekwowane; nieobsługiwane reguły dostępu nadal blokują zapis.", "webServiceHtaccessHelp": "RustProxy kompiluje ograniczony podzbiór zgodny z Apache podczas zastosowania Web Service. Pliki nie są parsowane przy każdym żądaniu; po zmianie .htaccess na dysku zastosuj Web Service ponownie.", "webServiceHtaccessDocsTitle": "Zgodność .htaccess", "webServiceHtaccessDocsIntro": "To warstwa zgodności przeznaczona do migracji, a nie pełne środowisko Apache. Wspierane dyrektywy są kompilowane do reguł Web Servera RustProxy.", @@ -2238,7 +2240,7 @@ "webServiceHtaccessDocsReloadTitle": "Ładowanie i limity", "webServiceHtaccessDocsReload": "Pliki są odczytywane i kompilowane podczas „Validate, save and apply”. RustProxy nie parsuje .htaccess przy każdym żądaniu. Po zmianie pliku zastosuj konfigurację ponownie. Skan ma limity: 128 plików, głębokość 16, 128 KiB na plik i 1 MiB łącznie.", "webServiceHtaccessDocsUnsupportedTitle": "To nie jest pełny Apache", - "webServiceHtaccessDocsUnsupported": "ErrorDocument, SetEnvIf, Redirect/RedirectMatch i FallbackResource nie są zaimplementowane w tej warstwie. Ogólne Files/FilesMatch, niewspierane dyrektywy uwierzytelniania/autoryzacji, handlery inne niż PHP i SetHandler są odrzucane nawet przy wyłączonym trybie ścisłym, ponieważ ich ciche pominięcie mogłoby osłabić kontrolę dostępu lub ujawnić kod źródłowy. Pliki .htaccess/.htpasswd są zawsze blokowane przed wysłaniem przez HTTP. Pozostałe niewspierane dyrektywy niesecurity są logowane i ignorowane, chyba że włączono tryb ścisły.", + "webServiceHtaccessDocsUnsupported": "ErrorDocument, SetEnvIf, Redirect/RedirectMatch i FallbackResource nie są zaimplementowane. Order/Allow/Deny z all, IP lub CIDR (IPv4/IPv6) są obsługiwane i egzekwowane. Ogólne Files/FilesMatch, nieobsługiwane dyrektywy uwierzytelniania/autoryzacji i reguły dostępu po nazwie hosta, handlery inne niż PHP oraz SetHandler są odrzucane nawet przy wyłączonym trybie ścisłym, ponieważ ich zignorowanie mogłoby ujawnić chronione zasoby. Pliki .htaccess/.htpasswd nigdy nie są udostępniane przez HTTP. Pozostałe nieobsługiwane dyrektywy niezwiązane z bezpieczeństwem są logowane i pomijane przy wyłączonym trybie ścisłym.", "webServiceHtaccessDocsSecurity": "ACL vhost/location, uwierzytelnianie, strony błędów i reguły odpowiedzi nadal mają nadrzędną rolę. .htaccess nie może wyjść poza document root, wybrać dowolnego socketu FastCGI ani nadpisać chronionych nagłówków transportowych.", "webServicePresetTitle": "Preset konfiguracji", "webServicePreset": "Preset", @@ -2618,13 +2620,13 @@ "locationErrorFallbackTarget": "Cel fallbacku błędów", "locationErrorFallbackStatuses": "Przechwytywane kody statusu", "locationErrorFallbackHelp": "Opcjonalny fallback błędów w stylu Nginx. Wskaż ID włączonej lokalizacji wewnętrznej. Obsługiwane statusy: 403, 404, 500, 502, 503, 504.", - "webServicePhpPathInfo": "Włącz rozdzielanie PHP PATH_INFO", + "webServicePhpPathInfo": "Włącz dzielenie FastCGI PATH_INFO", "phpProfileSelect": "Konfiguracja PHP-FPM", "phpProfileLocal": "Konfiguracja lokalna", - "phpProfileHelp": "Wybierz wspólny profil PHP-FPM lub skonfiguruj usługę samodzielnie. Zmiana profilu dotyczy wszystkich przypiętych usług.", - "phpProfileManage": "Zarządzaj profilami PHP-FPM", - "phpProfileToolbar": "Profile PHP-FPM", - "phpProfileTitle": "Wspólne profile PHP-FPM", + "phpProfileHelp": "Wybierz współdzielony profil FastCGI lub skonfiguruj usługę lokalnie. Zmiany profilu dotyczą wszystkich przypiętych usług.", + "phpProfileManage": "Zarządzaj profilami FastCGI", + "phpProfileToolbar": "Profile FastCGI", + "phpProfileTitle": "Wspólne profile FastCGI", "phpProfileDescription": "Rozwiń profil, aby go zmienić. Zapis od razu aktualizuje wszystkie przypięte serwery WWW.", "phpProfileAdd": "Dodaj profil", "phpProfileNew": "Nowy profil PHP-FPM", @@ -2645,10 +2647,10 @@ "backendHealthOverridesHelp": "Bez nadpisania backend dziedziczy ustawienia vhosta. Wylaczenie monitorowania nie blokuje lokalizacji przypisanych do backendu, ale wylacza probe aktywna i pasywne wykluczanie.", "cacheOnlyHits": "Pokazuj naglowki RustProxy tylko dla HIT (zachowaj naglowki backendu)", "cacheDetailedStatus": "X-Cache pokazuje STALE i REVALIDATED zamiast HIT", - "phpHintEnabled": "Uruchamia pliki o wskazanych rozszerzeniach przez już działającą pulę PHP-FPM. RustProxy nie uruchamia PHP; inne pliki nadal są statyczne.", + "phpHintEnabled": "Włącz wykonywanie wybranych rozszerzeń przez już uruchomiony PHP-FPM, wykonawcę CGI lub serwer FastCGI. Backend musi być dostępny.", "phpHintPathInfo": "Rozdziela /static.php/skins/file.css na SCRIPT_FILENAME=static.php i PATH_INFO=/skins/file.css. Potrzebne np. w Roundcube; zwykle zbędne w WordPressie. Domyślnie wyłączone.", "phpHintPassAuthorization": "Przekazuje nagłówek Authorization do PHP jako HTTP_AUTHORIZATION (np. API/Bearer/Basic). Wyłącz, gdy aplikacja go nie używa.", - "phpHintExtensions": "Rozszerzenia oddzielone przecinkami, bez kropek: php, phtml. Tylko te rozszerzenia uruchamiają PHP.", + "phpHintExtensions": "Tylko te rozszerzenia uruchamia wybrany backend. Dla PHP-FPM użyj php, dla CGI/FastCGI np. cgi lub fcgi. Pozostały kod wykonywalny nie jest serwowany jako plik statyczny.", "phpHintConnectTimeout": "Limit łączenia z gniazdem PHP-FPM w milisekundach: 1000 = 1 sekunda. Zakres: 50–60000.", "phpHintRequestTimeout": "Limit całego żądania FastCGI w milisekundach: 30000 = 30 sekund. Zakres: 100–3600000.", "phpHintConcurrency": "Maksymalna liczba równoległych żądań PHP na usługę, np. 64. Przekroczenie zwraca 503. Zakres: 1–4096.", @@ -4434,6 +4436,10 @@ "vhJsonDraft": "Niezastosowane zmiany JSON", "vhJsonReloadConfirm": "Odrzucić niezastosowane zmiany JSON i wczytać aktualne wartości formularza?", "vhJsonInvalidAcl": "Użyj null albo obiektu ACL z domyślną akcją allow/deny i regułami IP/CIDR.", - "vhJsonInvalidPaths": "Użyj tablicy zawierającej najwyżej 64 obiekty lokalizacji." + "vhJsonInvalidPaths": "Użyj tablicy zawierającej najwyżej 64 obiekty lokalizacji.", + "webServiceFastCgiHandler": "Tryb FastCGI", + "webServiceFastCgiHandlerHelp": "Wybierz backend: PHP-FPM wykonuje PHP, fcgiwrap uruchamia programy CGI, a ogólny responder FastCGI obsługuje zgodne aplikacje. Dla różnych katalogów lub socketów użyj osobnych Web Service i lokalizacji Vhost.", + "webServiceFastCgiScriptPrefix": "Publiczny prefiks SCRIPT_NAME", + "webServiceFastCgiScriptPrefixHelp": "Jeśli reguła Vhost usuwa prefiks URL (np. /app/cgi-bin), wpisz go tutaj. Prefiks jest dodawany do SCRIPT_NAME; SCRIPT_FILENAME pozostaje w katalogu usługi." } -} \ No newline at end of file +} diff --git a/src/admin/documentation/documents.rs b/src/admin/documentation/documents.rs index d889cae..240e7b7 100644 --- a/src/admin/documentation/documents.rs +++ b/src/admin/documentation/documents.rs @@ -25,6 +25,7 @@ pub(super) static READER_DOCUMENTS: &[(&str, &str, &str)] = &[ reader_doc!("docs/ACCESS.md", "guides"), reader_doc!("docs/WEB_SERVER.md", "guides"), reader_doc!("docs/PHP_FPM.md", "guides"), + reader_doc!("docs/FASTCGI.md", "guides"), reader_doc!("docs/CACHE.md", "guides"), reader_doc!("docs/CACHE_TEMPLATE_LIBRARY.md", "guides"), reader_doc!("docs/VCL.md", "guides"), diff --git a/src/admin/openapi.json b/src/admin/openapi.json index 76953de..4877061 100644 --- a/src/admin/openapi.json +++ b/src/admin/openapi.json @@ -2,7 +2,7 @@ "openapi": "3.0.3", "info": { "title": "RustProxy Administration API", - "version": "0.42.1", + "version": "0.42.2", "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": [ @@ -6806,9 +6806,25 @@ "maxLength": 8192 }, "description": "Trusted operator PHP-FPM administrative php.ini directives packed into PHP_ADMIN_VALUE. Restrict access to FastCGI endpoints." + }, + "handler": { + "type": "string", + "enum": [ + "php_fpm", + "fcgiwrap", + "fastcgi" + ], + "default": "php_fpm", + "description": "PHP-FPM, a CGI runner such as fcgiwrap, or a general FastCGI responder. Existing PHP configurations default to php_fpm." + }, + "script_name_prefix": { + "type": "string", + "maxLength": 256, + "default": "", + "description": "Fixed public URL mount prefix prepended to SCRIPT_NAME when the Vhost route strips or rewrites a URL prefix. SCRIPT_FILENAME remains inside the Web Service document root." } }, - "description": "Optional bounded direct FastCGI connection to a PHP-FPM pool." + "description": "Optional bounded direct FastCGI connection to PHP-FPM, a CGI runner, or another FastCGI responder." }, "htaccess": { "type": "object", @@ -6839,7 +6855,7 @@ "strict": { "type": "boolean", "default": false, - "description": "Reject Apply when an unsupported directive is found instead of logging and ignoring it." + "description": "Reject unsupported non-security directives during Apply instead of logging and skipping them. Unsupported access-control and handler constructs are rejected regardless of this setting; supported Order/Allow/Deny IP/CIDR/all rules are enforced." } }, "description": "Migration-oriented Apache .htaccess subset compiled at Web Service apply time; never parsed per request." @@ -13268,6 +13284,53 @@ } } }, + "/api/web-services/htaccess-warnings": { + "get": { + "summary": "Compiled .htaccess warnings for Web Services", + "tags": [ + "Configuration" + ], + "operationId": "get_api_web_services_htaccess_warnings", + "description": "Authenticated read-only snapshot. Returns {revision, services:{id:{files_loaded,warnings:[file:line:reason]}}} for configured .htaccess services. Warnings describe non-security directives skipped because Strict is disabled. Unsupported security directives fail validation instead of appearing as warnings. No disk scan is performed per request.", + "security": [ + { + "AdminSession": [] + } + ], + "responses": { + "200": { + "description": "Compiled diagnostics from the active configuration", + "content": { + "application/json": { + "schema": { + "type": "object" + } + } + } + }, + "401": { + "description": "Authentication required", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + }, + "403": { + "description": "Host or session access denied", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + } + } + } + }, "/api/config/{section}": { "put": { "summary": "Replace one configuration section atomically", diff --git a/src/admin/router.rs b/src/admin/router.rs index 18f5890..cf9739d 100644 --- a/src/admin/router.rs +++ b/src/admin/router.rs @@ -183,6 +183,7 @@ pub fn router(state: Arc) -> Router { .route("/favicon.svg", get(panel_assets::serve)) .route("/healthz", get(|| async { Json(json!({"status":"ok"})) })) .route("/api/status", get(status)) + .route("/api/web-services/htaccess-warnings", get(web_service_htaccess_warnings)) .route("/api/system-info", get(system_info)) .route("/api/backends", get(backend_status)) .route("/api/alerts", get(alerts_status)) diff --git a/src/admin/status_live.rs b/src/admin/status_live.rs index a62d1e0..839c935 100644 --- a/src/admin/status_live.rs +++ b/src/admin/status_live.rs @@ -11,6 +11,15 @@ fn live_chart_system_payload(state: &App) -> Value { }) } +async fn web_service_htaccess_warnings(State(state): State>) -> Json { + let snapshot = state.config.load(); + let services = snapshot.web_php_services.iter().filter_map(|(id, service)| { + let (files_loaded, warnings) = service.htaccess_diagnostics()?; + Some((id.clone(), json!({ "files_loaded": files_loaded, "warnings": warnings }))) + }).collect::>(); + Json(json!({ "revision": snapshot.envelope.revision, "services": services })) +} + fn web_server_metrics_payload(snapshot: &crate::config::Snapshot) -> Value { let mut services = serde_json::Map::new(); for service in &snapshot.envelope.config.web_services { diff --git a/src/admin/web/index.html b/src/admin/web/index.html index 4319fb8..014ecb2 100644 --- a/src/admin/web/index.html +++ b/src/admin/web/index.html @@ -921,7 +921,7 @@ data-i18n-placeholder="webServiceSearchPlaceholder" id="web-service-search" type="search" /> + id="web-service-php-profiles-open" type="button">FastCGI profiles @@ -4864,6 +4864,7 @@ curl -sS -D - -o /dev/null \ checked />Scan subdirectories +

When Strict is off, unsupported non-security directives are skipped and logged as warnings. Legacy Order/Allow/Deny with all, IP and CIDR are enforced; unsupported access-control rules still block Apply.

RustProxy compiles a bounded @@ -4982,7 +4983,7 @@ curl -sS -D - -o /dev/null \

- + + -