diff --git a/CHANGELOG.md b/CHANGELOG.md index c7eaabc..15f6c72 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ Release history focused on **features, settings, default behavior, compatibility ## 0.42.3 — Offline Cloudflare-style status pages +- **Page design and success-status hotfix:** show a single status code, label 200 as `HTTP 200` instead of an error, preserve bodyless HTTP 204 when enabling the bulk style, replace the RP mark with the official RustProxy SVG logo, and remove the decorative frame around the bulk switch. Add independent offline welcome/congratulations and placeholder choices in Settings, Vhosts and 404 hosts (existing status restrictions unchanged). The API accepts `cloudflare_welcome` and `cloudflare_placeholder`; old values and existing configurations remain compatible. Added regression tests and updated the generator and guides. Source-only patch; rebuild and run Rust tests before deployment. + - **Reversible bulk Cloudflare switch:** Settings → Pages and Vhost → Pages now provide an accessible on/off switch instead of a one-way action. On applies Cloudflare style to the selected scope; off clears its page/status overrides to the default/inherited responses (and disables Vhost application-error interception). The switch reflects manual edits, does not alter other Vhosts, and requires explicit Save. - **Page design refinement:** render all 13 self-contained templates using the familiar three-node diagnostics band, connecting arrows, green/red status indicators, two explanation columns, and an RP logo replacing the cloud. Remove the old verbose attribution footer and all Cloudflare navigation links; no external assets or fictitious Ray IDs. - **Bulk selection scope:** Settings → Pages can switch direct-IP, unknown-host and all global error pages to Cloudflare style in the current unsaved draft. The Vhost Pages switch also covers response/fallback and enables interception of all supported application-error statuses for that Vhost. HTTP status overrides are preserved when enabling the switch; changes require the normal explicit Save operation. English and Polish labels and documentation were updated. diff --git a/README.md b/README.md index 3c9cc21..6cbf446 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ | Delivery | Shared memory and disk cache, `Cache-Status`, purge/ban, gzip/Brotli/Zstandard compression, asset minification | | HTTP policies | Named ACLs, nested conditions, maps, transaction variables and staged header/routing/cache actions; HAProxy subset import and cooperation with existing VCL | | Monitoring | Live dashboard, per-Vhost statistics, live and stored logs, Prometheus exporter, JSON metrics, Grafana and Nagios | -| Operations | Configuration history and restore, encrypted backups, Docker discovery, Nginx Proxy Manager import, REST API with OpenAPI, offline Cloudflare-style error-page templates | +| Operations | Configuration history and restore, encrypted backups, Docker discovery, Nginx Proxy Manager import, REST API with OpenAPI, offline Cloudflare-style status, welcome and placeholder templates | The complete list is in [Feature list](docs/FEATURES.md); a visual tour is in [Screenshots](docs/SCREENSHOTS.md). diff --git a/SHA256SUMS b/SHA256SUMS index d15d637..25fe4af 100644 --- a/SHA256SUMS +++ b/SHA256SUMS @@ -2,12 +2,12 @@ 4140a2956264b44f259e6a37fc00ba02097bbe68b09296e04d3d243c1287129b .env.example 0a5e87541831edca0e7164c6469dba01a8a7053ab14dbfb8019c83e4db10edc2 .gitignore 6aa53a984cdecafd7615613b3f2eae9726144f9bc6e450d7f9efd8295d1db0ef AGENTS.md -a07f31d5f04fa548e613e08f061fccdb9ec2d58a2daa6f74b16ac24ca5634d1c CHANGELOG.md +485258b8d7fb31dfb1e8540557b2a72c49673b3a5e76fce64e0f7b4123b05579 CHANGELOG.md 1c8f3faa8c8ba133f78ff90e7bc5a590a3a277fff00a7c77babfdc0b5853cd58 Cargo.lock 9a0ed20f512cbc753fba1825e7e3934aa4e737c358887de64694e6123b228373 Cargo.toml 788745d4f70a0382c6280020afbd48844bb2af65e835a826852143f8132cdeca Dockerfile 0d96a4ff68ad6d4b6f1f30f713b18d5184912ba8dd389f86aa7710db079abcb0 LICENSE -61494937ed179d2d61abd8f5ae3e74a771b91e45af0d633aa0aa884de005ba82 README.md +a8d456f1b84dbc5f412f7dda9b98b4e765578111d31e7b26027aeb83c26f3f54 README.md da8311e3db945290666324a2f24bf4521b365272d7ac3f862ded1be993eea646 UPDATE_CHECK.toml 120609370b79e192c9a2a72c1706225aa5da06c5806efa26a010b733e120322b build.rs 95ececaba550a4bcfd6754073877ba0633373b1e1451521b9ac905a51e8ca6eb deploy/README.md @@ -48,9 +48,9 @@ bfe96dd91dfc6e07918a662d98b036f12ceb011a5aa8381b3778bd0c964b19ab docs/CACHE.md 2cede323fe2767100258b5e1d3e3a8b362e2a91acf2b0ee61090c4a2db97d952 docs/CUSTOM_LOCATIONS.md 16d4510e38d43c3bbde9b7dab7af3aeb0cb837dc2f1956cfaad7a9a11bea3bfc docs/DASHBOARD.md 53cb0ce7db5ce25e4c2381de3a6e875d212deeed08861da63050de6c51a442bd docs/DOCKER_DISCOVERY.md -6e3ee12901fd45691f8becbcf3f1edb749a27b44775ff93035ff594bd8c43388 docs/ERROR_PAGES.md +01c58be33a02f838e7b30ece3127df18744f7c3d35e0731759d407e1575b75f3 docs/ERROR_PAGES.md 3e729724030fd38d2d77272fddbb6509b7cd971c6bf0e9e3ef234ad69e342156 docs/FASTCGI.md -96c4785a7b7f44c050ed664b2ce2e40e4acb9d35e003bdb1b9d811f616290447 docs/FEATURES.md +01b6d461d6b17b321d63cfb51435814858b29b437ed3e0bb13aba4351eaaf735 docs/FEATURES.md f7bb59821e0d6c45ae2a1789086fd9dab33d91c0ceae784ae68f64bd13b5f496 docs/HEADLESS.md bce732d845c23ad677ae811e7529b9322ab41d04ca808e04087d0f76bccd9309 docs/INSTALL.md 3268808766ad66263e465f251dce18cff2e7ede355638dc2b0975870b1a5eead docs/LOAD_BALANCING.md @@ -60,7 +60,7 @@ e5e50be31b3160588599336b1871b07a1e829b202454a67d2dc4e2e754d23eab docs/LOGS.md 6d3937088eeb67a9f690d44ebe0b6e660b68116dbf69091ac7816bdc52cec2b6 docs/PERFORMANCE.md a8fdd52601f45a19fd194e27d6ce40aaf57603e88633f8d7040775599494e124 docs/PHP_FPM.md 45ce24998bda40e60f34756bef29616114aec9fd5cdd5e1aed692ff2371a3af1 docs/POLICY.md -9f729c63a50ea5d6454b6c87ac6d4af00b64fcfb1415dc94621d16ff141b3783 docs/README.md +54e9e771707777144105a59c4d6dd6589cc74d735aea660af5366283cf820ee6 docs/README.md e90842a75459ddb5892334f66a4139d9301280b4d0c17077d211749bd7c90d80 docs/RESPONSE_DELIVERY.md 95ab4786792d5920a2e109b7d196838057f24b512a69d713fb5884dc75c84339 docs/SCREENSHOTS.md 3a48184b36d225757fc5e2d22c629f89bfe5d4007ff087f0be0ce02a5fb04c28 docs/SECURITY.md @@ -71,8 +71,8 @@ df83d07d7186a5eea60d206dee3cb62b7f6505a066d84141fc53130e2f29760b docs/TROUBLESH 53005e1eeb460c960794e2b2f1ab7cfc472c510b14bea3193d25f5f81ba7a1e4 docs/VCL.md 4a5534b628c18f4e83c67c6136b60969c884391fbe55cc6bd4f2354711d8ffb7 docs/VCL_SUPPORT_MATRIX.md 382e084a1f9e35627ccb43eaf451c18fb6d0cc752397c2178108d71de592a931 docs/VCL_TRAFFIC_COOKBOOK.md -173488ca17e2280685672154a851e9b5c91e95cf751cedf91df002de5b75c472 docs/VHOSTS.md -c806f984ab2da8e711a1b4d144ccac9e4e10dc6ef28c5ba852ed767cd1fcc914 docs/WEB_SERVER.md +657720a2b093ba8c08c2bf2c01b02a0f95fd3c67751868d1d1cc1dbf31b633e5 docs/VHOSTS.md +0a624f8aa3e004ba37a93bbb13420db26837a9dd360f2bb672a4ed33e6931f0f docs/WEB_SERVER.md 42822b1c9801bcadb0e2d785cb91883ca2df1da141222631f153030c95f5e197 docs/images/about.png deff2393a987ac7102179dc85b48baf2c4a3882291bb8c7c584d760cc497c631 docs/images/api.png 74df8228ea6283004b3e87b4d297e43637371eb4a700b69c7248114c8670777a docs/images/cache.png @@ -138,8 +138,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 -5f4e6b84c28f36f28b79750b5f5b09e7827ea1fec7102580912a3982fe5c67d7 langs/en_US.json -ab1c4d5fe6d28d1c9c8eec359a6973602ef764e42e9b5192dd5b40489b9eeb2f langs/pl_pl.json +ebc5205910072c105d5b95b69f5c4994ce11373eabbd762e94f4633aa88e5f31 langs/en_US.json +805e05923939b558f3282e92226d7e501f31612eb8f6ea98308f22cad89ac296 langs/pl_pl.json 38773ed251a8c24af353f4744e498ae2bc7d4151df7927e942c4ac223f6008e1 make_zip.py e830d37dd1f81a4b0aa7d535f5bba69e34e433b0fd99cc8ee0b296786c32379a migrations/0002_admin.sql 20112cc82192098b8d602f1c4f7ca08712e9e1366c845fabb92753187c370d35 migrations/0003_certificate_renewals.sql @@ -170,7 +170,7 @@ e4d15aa6aa864d04b9b30aca33826b833632af02ca643f8b23e219a5ea1298dd scripts/deploy f0edbdca3af49cfa8f9c118d3eb0977c99569264dc5d74a85c4610234ea1fe88 scripts/deploy/deploy_core.py f26297284e0ad9fb4e4317deac24b25de819c10d04fed551134ddb6debc41837 scripts/deploy/deploy_runtime.py a59587ce8ad41b1bbb431356b58398f9c8ff7cb96a613a91752e907a70e10c2e scripts/deploy/upgrade.py -99cadfdf960c63ca152cb6136e7a906e3a8a3b9cee006e401d6fb10469375cbe scripts/generate_cf_pages.py +3c3a50d0a7bf32852cf50c4383d1f30962b4728b094b2e2ec63fef699c3792c8 scripts/generate_cf_pages.py 2cc658faaa610b21b48942c59b955525539ad4503fd60f2a49c7e626a22faaff scripts/migration/migrate_npm.py a459d95bbb0076f33ade8b273b813308167f9d8d45242b309a2d18320ca0093c scripts/migration/migrate_npm_api.py 4c905a387f210c30fbf12a7738676fd39819bc96bc4a272da1db5f18a2d3013e scripts/migration/migrate_npm_core.py @@ -182,7 +182,7 @@ e69813fb1d3a4cdcfb7243964cc323fc21a603087bf2e84188fa42b9d3cee4b5 scripts/runtim 22e880e98c7b9d700c7a4c02b9b1d543e5dbd1f4ecdca42813a1083165b32a19 scripts/version.py 78efae6c43732c0f5527d467bf07d1f890da361925416c89b58bc449d852fc2b src/acl.rs f097cce1f831e01b68688eb60c1b6393413131e6543c4627f3cedd9ef706193b src/acl/dynamic/mod.rs -978fdb2f61b7f04245609a275cd80a7f473c89ce7205d3aff1fd1f11ffacd7aa src/acl/dynamic/tests.rs +0b10c7f6086086754d2bca22fb04116d534bf461d36b0b6bcaf20c0b42996b2a src/acl/dynamic/tests.rs 50d9a0009cdcee6dd34a6215755d98f38ea18fa39b9faf070d1a7649eeac6aae src/acl/tests.rs f15b5bb11e2b949d7ed203711275b24b3f76de2ab617ef8b7345585c15ca34bd src/acme.rs 767d2f26fa8dea4ff6717d1e20ac0611b83bd20ab64bda8163cc6a5cc4dcb614 src/acme/headless.rs @@ -214,7 +214,7 @@ f9b2c8fe62cc92d7693e46145b2543b12dd6d4943fe2d52c67ed6958d4af83de src/admin/docu e2253599b5e39510946729920d240711403a3889cc495eb49824296228f1d080 src/admin/file_logs_query.rs 1594c8666991c1d07487a6a718211ef404cf49114721960f7e119bb7f605e3d2 src/admin/logging_api.rs 781fd5f176dd8f2372f75bd90edcf160708e2d0a8d6a115ba4b283c0cd49eb2d src/admin/mod.rs -811f04d59aa39d9221da412c857ccc602b3824f183a6c5c9add8af1c6191d72e src/admin/openapi.json +e3a2142fa7244c08c88bcf5829c4cbab9e42388c22aaef5970ed075fe7022f1e src/admin/openapi.json 9f8842cdec27d703d1795dd6eb37d9420e9f5a2e56a0df93278c92bace5d1f4c src/admin/operations.rs 257d93a29d0bda96462bcf695aba8d0ec0f9412c379e066ec46ae8ee034e3a53 src/admin/panel_assets.rs f5127855c2994d052678865df36d703b74f4a0afc633daf7718b10da18d26e37 src/admin/panel_content.rs @@ -268,22 +268,24 @@ b7ead49224a4ec67181d3f24f9d9634bd6d76756f826a4d5d993300637d1d8f3 src/admin/web/ ba22ff211f408052aee0aa75a5a52734b1c257247e7112972aff75a9646faf22 src/admin/web/cache-panel.js 433f5ccf0a4df1c4452f746f7b2f351f6712ee73873cb07204638c205e4f2c88 src/admin/web/cache-rules.js 6288b0a8228d828ac2e2535ace2d1aefd1c04011e789eb97f7279129874ac35c src/admin/web/certificate-api.js -8d34215c30c2969aa89b9e0e89d3d2cafcae2cab0025b08d342ef074a74ec8bc src/admin/web/cf_page/README.md -c98e5545fc5e64eb7d0ca41424abf015803aa4c682bfe2fb6a892d002ae18fd3 src/admin/web/cf_page/error_200.html -58546965228b4443d97502b1920a7ad2e27e247fa8145857a8cf87171930f484 src/admin/web/cf_page/error_400.html -3c1fb632fc0ddb4aa2b1cf8a534e74d86290ca9ad9a3731e667f98865dd37945 src/admin/web/cf_page/error_401.html -525443803b238f5310abd172ec91dbac3e183dbc63f0b8847da964031805c14f src/admin/web/cf_page/error_403.html -502868b3908809464f9361edca574bef99aad7fbba63e46c5a67c6416732ca22 src/admin/web/cf_page/error_404.html -5d279a39314e53b1c814c60fb119032c3d4636415361b304f3964725c20b20cb src/admin/web/cf_page/error_408.html -c62b1dc1e8a0571fb3ea7b6bc403c948ad0c7f7c6773fca8f9430c8279d24a1f src/admin/web/cf_page/error_410.html -69bee85a2508ef531dd88e6b9ea9e4945df0d0e33d748e49be3a794074f774ce src/admin/web/cf_page/error_413.html -66f47a689506e248cf0f414d2bc2de93231a038680bf8a44a5ec4a72b326ca7e src/admin/web/cf_page/error_429.html -d027603a94a370b57d787cb086a7711abba1a16cd6dd6d9e4e4f3dcd3b48cbfa src/admin/web/cf_page/error_500.html -18c85261284721921d8e24db1bdda7282b7a567eabd34b93039ea5210792d700 src/admin/web/cf_page/error_502.html -1746db4b9a4c69b4f8a371585a71992082ecb9a68f9141f085f8bff66b7bc04c src/admin/web/cf_page/error_503.html -cf4802aa6066dd17a8ac73012d2ade614965bfed55c35257091c1396368b3e75 src/admin/web/cf_page/error_504.html +acfdf7a31a7f3d1a7636125d724f9348ac397a1081344046e67fce2620e37fd6 src/admin/web/cf_page/README.md +b451834f933cc09583ee0401223fa826ea69943535e24b9700cb115ec2283339 src/admin/web/cf_page/error_200.html +110f0fc283a9803eb929a62b17bb935eafa3729c684c4ccd0a783ad1294d6185 src/admin/web/cf_page/error_400.html +44b67697ad9dab55f204ffaff76ea2b5344cd759d227081beeff79e2dfe920d1 src/admin/web/cf_page/error_401.html +90019ccd0485c009157d99bac6e6979a6fbc607d09b22be524805cbb0b200988 src/admin/web/cf_page/error_403.html +695cd2c96e19d7fc5076bdbd61ca37f29ad6f1ff3c04d259fac61b045f43d031 src/admin/web/cf_page/error_404.html +c6e865b0bfee0e2dcc2fe570bc81bcc269713067a36aa792b6058faaf83c128a src/admin/web/cf_page/error_408.html +f059f0c47f31b8b58104d1267ce291dc158f36168a109666bbdc8e39f09fdf88 src/admin/web/cf_page/error_410.html +671c7de4776e11bcf95886cc882edabfd426d43d9fe453cf691e4d18c53df588 src/admin/web/cf_page/error_413.html +d8e06e53074addedc9bfe6a39e60d0ab1b1d0539a32c31b848a7f0a21dcbbb42 src/admin/web/cf_page/error_429.html +dc7c4b2ef058fcf806e26d30b45f733812c05eb96f865ee6d83861c832cc10d4 src/admin/web/cf_page/error_500.html +f622ff59cc971bf2bcda5786e3a10a6607309b4efd00ab3feb9376e157ce2a45 src/admin/web/cf_page/error_502.html +f4f0e8eec39762bf263dcade63aa37110c483fcd9c8337e65f9f0ccfcbba8f5d src/admin/web/cf_page/error_503.html +ece171f4d6246d5c465bed1deddad4150c7225fc72efc99b5f1b4d0875b300c1 src/admin/web/cf_page/error_504.html +46d1dc7f2450075f5333dd44875c5f76094503cdd3a5e66f2ca0358e38b00fc3 src/admin/web/cf_page/placeholder.html +f0d06f462530aaa484a49763c5e00f0009b6e291469295c9209bd1b3418053bc src/admin/web/cf_page/welcome.html c2912a5e218896177776d4c5920e240092a3de66f9a4b95c1631796771e0ce3c src/admin/web/css/00-tokens.css -c7ed598c3f19005971871259ea7ee7cc8a6910a8e0e0d25ad38a6d003951e081 src/admin/web/css/10-base.css +03fcd3917f84eb995bfea8ffebd261c90cae3733e26c2dcac2be3a7d5edd60ec src/admin/web/css/10-base.css 9cd9b62ff8cfba47cb180e29ea5f69b8e97c7817dfcfddcb55fc4e08d11a7184 src/admin/web/css/20-shell.css 5af483ff7937ff245d8718179dc6001716d2b279f6ce935f5aa0c9fcfa370ab8 src/admin/web/css/30-overview.css 2763ff8969567cbd001ba4b5d5b669aea7aec347088ffe7c2b164b82396755d5 src/admin/web/css/40-editors.css @@ -317,13 +319,13 @@ e6c4d91d1542d0a5b47bb8736f9539d43a6713df5a473b635519d5b7eac2eb9c src/admin/web/ 003d382cc8dd69ad7237679632c04a9389366bb71dd7dca8ee64ee06614aa9a5 src/admin/web/error_auth_provider.html 0a5fff35555153f59d4346933030a67b6e1a8768cee7a47cfa2fcf1a2c564f63 src/admin/web/favicon.svg e0f0b302092ced1c84ef7e99864984444f0e9d4e3b7d85e74d3507d566952a7f src/admin/web/file-logs.js -7cf7566485a61d5b88a4742a567f59ec1050735727479fa428378bb79472527e src/admin/web/host404.js -278f061b529ad95af3a4a5e7861f4b29c52528bb700187bbd60e394e284649f6 src/admin/web/index.html +9a243e651984cf0b84649c89ed0452d4961f5384c00909403fc640768ed3feef src/admin/web/host404.js +a066fc38de115ac5b9c76cee73a14f47b9df43370a45c9cf8fec8f2bda8cbb60 src/admin/web/index.html be9999a001c59630963d60539e860b59999dcf74c5ff0087b12a6fb69b4e7bd2 src/admin/web/integrations.js 7a12f020fc587205694978ab41b660e9a80487d413fbf6e34fc525eabc58308f src/admin/web/login-keys.json ac9f667273918e18406df06cb2613c923f50a88897693a03a18f500e22dc6ec2 src/admin/web/login.html c2e5f554810b8e34fb47361fb90a01073a2e332ee26d82e030956fad3ec1f83e src/admin/web/login.js -732299f1b02da12d9fba047b49fa38351613feb5941141277dfd4e47abba3d0d src/admin/web/management.js +0704aad8f68d5e56a5ec33b3b80f072e086b455c8dcbe1dac9a0320cb518c9ca src/admin/web/management.js 1f3d10e389c9c20e6eb019509fa6e82b50c6b43bbf988c1210a4d42bb73985d0 src/admin/web/partials/overview-charts.html bd94e61e051a6bebe0afbda0a21aa36349c2067516b974986765555ed47455cc src/admin/web/partials/overview-metrics.html 8bb503677f51362dc3cc9522596affa65c5960ab5e44b1c935cb4abf85505429 src/admin/web/policy-presets.js @@ -495,12 +497,12 @@ f053cf4391b734ab9e8646caa194fe923b151a591f760558fdd28cd339d659e8 src/metrics/gl 4e71dcbd92d8afe5808eaee693243725e8b6515377de9837fce4623af98b383a src/metrics/vhost/mod.rs bb8507a5329ba320e4af02757f5f37da61db39fec147fcc2a3b76e3fcfd47434 src/metrics/vhost/tests.rs c456b31ddd7a5c209073812b288f2cc150b5cdb0ed9372d4d1a9a84a74d706cd src/not_found/mod.rs -78ab02e001d8590ee5c0da5a48558d1c9961673997f1f39109b8dbb2d463ce56 src/not_found/tests.rs +3d0819723f1014232dd80cdd0dff50d774fe1004d9ff4322831dfef974062e58 src/not_found/tests.rs c19998732c2d65b464f43d17a58644db5bcf7b4a6dd4c31a65a091c57692a5bb src/oidc/mod.rs c4dbe0f8ded237d45b6a3977bdc7544296e4408996815cae9e28af028419d0b7 src/oidc/tests.rs 992f49379e44361d98088d8f8ca1013d62846a54a5a35c089a5e0e1a9488e08d src/oidc/token.rs -f000fec66781122f70a7dee93e72c2e9ba33497b0e07d68e200f398b75746a76 src/pages/mod.rs -2eecf2089bb5b9491e714c13e8c455664365ac5f941513452371cff27b81eb14 src/pages/tests.rs +e05cc048830bf2ff47a3d95ef5372208be4bd0e043712b532e4a39280dd685e1 src/pages/mod.rs +3ebf39c7e7de2ad794625e67937991b65adcf4e8c9978061f21ad891b2238aaa src/pages/tests.rs 9840ec5b3786661084fefdced6694f3c099fef1e872e28fab9ef9a5cef29d141 src/policy/compile.rs 420d3e1133621a6bab8c15523cbd81712ea4b5d36c1390d52d5ef703164850c9 src/policy/engine.rs 12440a52f0a90f0f853f4a1273aef20b4b95137709dcf48345707aeef291df90 src/policy/expression.rs diff --git a/docs/ERROR_PAGES.md b/docs/ERROR_PAGES.md index e36234b..79e5f30 100644 --- a/docs/ERROR_PAGES.md +++ b/docs/ERROR_PAGES.md @@ -1,26 +1,26 @@ # 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. +RustProxy 0.42.3 offers three **Cloudflare-style (offline)** designs alongside the existing built-in, blank, welcome and custom HTML responses: status-specific, congratulations and placeholder. 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. +- **404 hosts → Response type:** choose a Cloudflare-style status page, welcome page or placeholder and a supported error status. The standalone 404 host remains restricted to error HTTP statuses. -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. +The two new designs are also selectable in Settings → Pages and Vhost → Pages. They show a welcome or placeholder message without implying an HTTP success/error code; the actual HTTP status remains independently configurable. 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. +The directory `src/admin/web/cf_page/` contains `welcome.html`, `placeholder.html` and generated status 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. +Status-specific pages contain one visible HTTP code in the heading: `HTTP 200` for success, or `Error 504` (for example) for errors. The welcome and placeholder pages have their own headings and advice without a fixed code in the HTML. All contain a three-node diagnostic visualization and short next-step advice. HTTP 204 No Content must use empty mode and never returns an HTML body. 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 the official RustProxy favicon embedded as an inline SVG 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. +Existing status overrides in the form are preserved when enabling the bulk action, including empty HTTP 204 responses. Already styled pages retain their selected variant; existing welcome pages are converted to the styled welcome or placeholder according to their scope. Turning the switch off clears the overrides as before. 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 @@ -38,10 +38,12 @@ Select the template for one global HTTP status without changing other error page 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. +For a welcome or placeholder response use `"kind": "cloudflare_welcome"` or `"kind": "cloudflare_placeholder"` in the same Page object. Use `"kind": "empty", "status": 204` for a no-content response. + ## 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. +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 `Bad gateway Error 502` and `RustProxy`. Re-test `401` with Basic Auth to ensure the challenge header remains. No Cloudflare account or public network access is needed. diff --git a/docs/FEATURES.md b/docs/FEATURES.md index 55f1efa..57993a3 100644 --- a/docs/FEATURES.md +++ b/docs/FEATURES.md @@ -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, offline Cloudflare-style static error templates with one-click per-scope selection and direct-IP pages | +| Redirects and pages | Redirect hosts, canonical host and HTTPS redirects, 404 hosts, custom error pages, offline Cloudflare-style status, welcome and placeholder 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 diff --git a/docs/README.md b/docs/README.md index 53a5dbb..5a55b20 100644 --- a/docs/README.md +++ b/docs/README.md @@ -26,7 +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. +- [Error pages](ERROR_PAGES.md) — built-in and offline Cloudflare-style status, welcome and placeholder 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. diff --git a/docs/VHOSTS.md b/docs/VHOSTS.md index 990602f..565039f 100644 --- a/docs/VHOSTS.md +++ b/docs/VHOSTS.md @@ -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. Since 0.42.3, it also offers a static, offline **Cloudflare-style** page option; see [Error pages](ERROR_PAGES.md). +- 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** status, welcome and placeholder options; see [Error pages](ERROR_PAGES.md). ## Safe operating practices diff --git a/docs/WEB_SERVER.md b/docs/WEB_SERVER.md index 57a540e..508d5ae 100644 --- a/docs/WEB_SERVER.md +++ b/docs/WEB_SERVER.md @@ -93,7 +93,7 @@ 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. +Since 0.42.3, **Settings → Pages** and **Vhost → Pages** can also select a pre-generated offline Cloudflare-style template for individual status responses, plus separate welcome and placeholder designs. 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. diff --git a/langs/en_US.json b/langs/en_US.json index 3811c50..f6a7d5d 100644 --- a/langs/en_US.json +++ b/langs/en_US.json @@ -556,6 +556,8 @@ "pageWelcome": "Congratulations page", "pageEmpty": "Empty response", "pageCloudflare": "Cloudflare-style status page (offline)", + "pageCloudflareWelcome": "Cloudflare-style welcome page (offline)", + "pageCloudflarePlaceholder": "Cloudflare-style placeholder (offline)", "pageHtml": "Custom HTML", "pageStatus": "Response status", "pageOriginalStatus": "Original status", @@ -1756,6 +1758,8 @@ "vhProxySendTimeout": "Proxy send timeout (s)", "vhProxyTimeoutsHelp": "Defaults: connect 10 s, response headers 120 s, read 60 s and send 60 s. Read/send are idle-gap timeouts for streaming bodies.", "notfoundModeCloudflare": "Cloudflare-style status page (offline)", + "notfoundModeCloudflareWelcome": "Cloudflare-style welcome page (offline)", + "notfoundModeCloudflarePlaceholder": "Cloudflare-style placeholder (offline)", "notfoundModeBuiltin": "Application-style status page", "pageBuiltin": "Built-in status page", "vhOpenBrowser": "Open", diff --git a/langs/pl_pl.json b/langs/pl_pl.json index 9922b98..5bbb26b 100644 --- a/langs/pl_pl.json +++ b/langs/pl_pl.json @@ -556,6 +556,8 @@ "pageWelcome": "Strona gratulacyjna", "pageEmpty": "Pusta odpowiedź", "pageCloudflare": "Strona w stylu Cloudflare (offline)", + "pageCloudflareWelcome": "Strona gratulacyjna w stylu Cloudflare (offline)", + "pageCloudflarePlaceholder": "Zaślepka w stylu Cloudflare (offline)", "pageHtml": "Własny HTML", "pageStatus": "Kod odpowiedzi", "pageOriginalStatus": "Oryginalny status", @@ -1756,6 +1758,8 @@ "vhProxySendTimeout": "Proxy send timeout (s)", "vhProxyTimeoutsHelp": "Domyślnie: połączenie 10 s, nagłówki odpowiedzi 120 s, odczyt 60 s i wysyłanie 60 s. Read/send to timeout bezczynności podczas streamowania body.", "notfoundModeCloudflare": "Strona statusu w stylu Cloudflare (offline)", + "notfoundModeCloudflareWelcome": "Strona gratulacyjna w stylu Cloudflare (offline)", + "notfoundModeCloudflarePlaceholder": "Zaślepka w stylu Cloudflare (offline)", "notfoundModeBuiltin": "Zaślepka aplikacyjna dla statusu", "pageBuiltin": "Wbudowana strona statusu", "vhOpenBrowser": "Otwórz", diff --git a/scripts/generate_cf_pages.py b/scripts/generate_cf_pages.py index c1dcd1b..17704ff 100755 --- a/scripts/generate_cf_pages.py +++ b/scripts/generate_cf_pages.py @@ -9,13 +9,17 @@ from __future__ import annotations from html import escape from pathlib import Path -ROOT = Path(__file__).resolve().parents[1] / "src/admin/web/cf_page" +WEB = Path(__file__).resolve().parents[1] / "src/admin/web" +ROOT = WEB / "cf_page" +# Use the exact dashboard brand mark: r / p with the same span structure, +# typography, dimensions and border styles as css/20-shell.css. +LOGO = 'r/p' # Code, title, explanation, advice, RustProxy status label, origin status label, # RustProxy indicator, origin indicator. Indicators describe this request only; # they must never claim to have checked the upstream's health. STATUSES = [ - (200, "Service ready", "RustProxy received and handled the request.", "You can continue to the requested service.", "Working", "Not checked", "ok", "unknown"), + (200, "Service ready", "RustProxy received and handled the request.", "No further action is required for this response.", "Working", "Not checked", "ok", "unknown"), (400, "Bad request", "The request was malformed or could not be understood.", "Check the request and try again.", "Request rejected", "Not contacted", "error", "unknown"), (401, "Authentication required", "This resource requires valid credentials.", "Sign in with an authorized account and retry.", "Authentication required", "Not contacted", "error", "unknown"), (403, "Access forbidden", "Access to the requested resource is not permitted.", "Contact the website administrator if you believe this is an error.", "Access denied", "Not contacted", "error", "unknown"), @@ -35,45 +39,49 @@ CSS = """ * {box-sizing:border-box} body {margin:0;background:#fff;min-height:100vh;font-size:15px;line-height:1.5;-webkit-font-smoothing:antialiased} .container {max-width:1030px;margin:0 auto;padding:0 24px} -.intro {padding:54px 0 44px} -h1 {font-size:49px;line-height:1.18;font-weight:300;margin:0 0 5px;letter-spacing:-1.1px;color:#313131} -.error-code {font-weight:300;color:#8d8d8d} -.subtitle {font-weight:300;font-size:25px;line-height:1.4;margin:2px 0;color:#777} +.intro {padding:54px 24px 44px} +h1 {font-size:46px;line-height:1.2;font-weight:300;margin:0;letter-spacing:-1.1px;color:#313131;overflow-wrap:anywhere} +.status-code {font-weight:300;color:#737373;white-space:nowrap} +.eyebrow {font-size:12px;letter-spacing:.12em;text-transform:uppercase;font-weight:600;color:#686868;margin:0 0 12px} +.success .eyebrow {color:#527b24} +.placeholder .eyebrow {color:#686868} .diagnostics-band {background:#f1f1f1;border-top:1px solid #e9e9e9;border-bottom:1px solid #e5e5e5} -.diagnostics {display:grid;grid-template-columns:minmax(0,1fr) 76px minmax(0,1fr) 76px minmax(0,1fr);align-items:start;padding:39px 0 36px;text-align:center} +.diagnostics {display:grid;grid-template-columns:minmax(0,1fr) 76px minmax(0,1fr) 76px minmax(0,1fr);align-items:start;padding:39px 24px 36px;text-align:center} .node {min-width:0;text-align:center} .symbol {height:107px;position:relative;margin:0 auto 11px;width:142px;max-width:100%;display:flex;align-items:center;justify-content:center} .symbol svg {width:118px;height:100px;display:block;overflow:visible} +/* Dashboard brand mark, matching css/20-shell.css (standalone page colors). */ +.symbol .brand-mark {font:700 33px ui-monospace,SFMono-Regular,Consolas,monospace;border:1px solid #f69b74;color:#f69b74;place-content:center;position:relative;box-sizing:border-box;padding-right:2px;display:flex;align-items:center;justify-content:center;letter-spacing:-3px;flex-shrink:0;width:47px;height:47px;font-size:29px} +.symbol .brand-mark span {font-size:22px;left:29px;top:19px;color:#cfe0ac;position:static} .symbol .ind {position:absolute;right:10px;bottom:10px;display:grid;place-items:center;border:3px solid #f1f1f1;border-radius:50%;height:37px;width:37px;font-family:Arial,sans-serif;font-size:24px;font-weight:700;line-height:1;color:white;background:#9bca3e} .symbol .ind.error {background:#c93135} .symbol .ind.unknown {background:#aaa;font-weight:500;font-size:26px} -.location {font-size:14px;color:#a2a2a2;margin:0;overflow-wrap:anywhere} +.location {font-size:14px;color:#676767;margin:0;overflow-wrap:anywhere} .node h2 {font-size:21px;font-weight:400;margin:1px 0 0;color:#545454;overflow-wrap:anywhere} -.state {font-size:16px;font-weight:500;margin:2px 0 0;color:#8cbb35;overflow-wrap:anywhere} +.state {font-size:16px;font-weight:500;margin:2px 0 0;color:#527b24;overflow-wrap:anywhere} .state.error {color:#c93135} -.state.unknown {color:#888} +.state.unknown {color:#666} .connector {padding-top:53px;min-width:0;color:#aaa} .connector svg {height:30px;width:100%;display:block;fill:none;stroke:currentColor;stroke-width:4;stroke-linecap:round;stroke-linejoin:round} .help {display:grid;grid-template-columns:1fr 1fr;gap:58px;padding:41px 0 45px} .help h2 {font-size:20px;line-height:1.35;font-weight:400;color:#333;margin:0 0 12px} .help p {font-size:15px;line-height:1.6;margin:0;color:#555} -.bottom {border-top:1px solid #e7e7e7;margin-top:7px;padding:22px 0 35px;display:flex;align-items:center;justify-content:space-between;gap:14px;color:#999;font-size:12px} -.brand {color:#858585;font-weight:600;letter-spacing:.02em} -.bottom .signature {font-size:12px} +.bottom {border-top:1px solid #e7e7e7;margin-top:7px;padding:22px 0 35px;color:#666;font-size:12px;text-align:center} +.brand {color:#454545;font-weight:600;letter-spacing:.02em} @media(max-width:700px) { - .intro {padding:35px 0 30px}h1{font-size:36px;letter-spacing:-.7px}.subtitle{font-size:20px} - .diagnostics{grid-template-columns:repeat(3,minmax(0,1fr));padding:25px 0;gap:4px} + .intro {padding:35px 24px 30px}h1{font-size:36px;letter-spacing:-.7px} + .diagnostics{grid-template-columns:repeat(3,minmax(0,1fr));padding:25px 14px;gap:4px} .connector{display:none}.symbol{height:76px;width:86px;margin-bottom:6px}.symbol svg{width:77px;height:70px} .symbol .ind{width:28px;height:28px;font-size:18px;border-width:2px;right:0;bottom:1px} .symbol .ind.unknown{font-size:21px}.location{font-size:12px}.node h2{font-size:15px}.state{font-size:13px} - .help{grid-template-columns:1fr;gap:24px;padding:31px 0}.bottom{flex-wrap:wrap} + .help{grid-template-columns:1fr;gap:24px;padding:31px 0} } -@media(max-width:360px){.container{padding:0 14px}.intro{padding-top:27px}h1{font-size:31px}.symbol{width:70px}.symbol svg{width:69px}.node h2{font-size:14px}.state{font-size:12px}} +@media(max-width:360px){.container{padding-inline:14px}.intro{padding-top:27px}h1{font-size:31px}.symbol{width:70px}.symbol svg{width:69px}.node h2{font-size:14px}.state{font-size:12px}} """.strip() ICONS = { "browser": '''''', - "proxy": '''''', + "proxy": LOGO, "origin": '''''', } @@ -88,43 +96,64 @@ def node(icon: str, location: str, title: str, state: str, indicator: str) -> st ) -def make_page(code: int, title: str, happened: str, advice: str, gateway: str, origin: str, - gateway_indicator: str, origin_indicator: str) -> str: +def make_page(code: int | None, title: str, happened: str, advice: str, gateway: str, origin: str, + gateway_indicator: str, origin_indicator: str, *, variant: str = "status") -> str: arrow = '' + is_error = code is not None and code >= 400 + theme = "error" if is_error else "placeholder" if variant == "placeholder" else "success" + status = f"Error {code}" if is_error else f"HTTP {code}" if code is not None else "" + code_markup = f' {status}' if status else "" + eyebrow = {"welcome": "Welcome", "placeholder": "Placeholder", "status": "Request status"}[variant] + heading = "What happened?" if is_error else "About this page" + next_heading = "What can I do?" if is_error else "What comes next?" return f''' -Error {code}: {escape(title)} | RustProxy +{escape(title)}{f' | {status}' if status else ''} | RustProxy - -

{escape(title)} Error {code}

Error code {code}

+ +

{eyebrow}

{escape(title)}{code_markup}

-{node('browser', 'You', 'Browser', 'Working', 'ok')} +{node('browser', 'You', 'Browser', 'Request sent', 'ok')} {arrow} {node('proxy', 'Gateway', 'RustProxy', gateway, gateway_indicator)} {arrow} {node('origin', 'Origin', 'Host', origin, origin_indicator)}
-
-

What happened?

{escape(happened)}

-

What can I do?

{escape(advice)}

-
+
+

{heading}

{escape(happened)}

+

{next_heading}

{escape(advice)}

+
Powered by RustProxy
''' +VARIANTS = [ + ("welcome", "Congratulations! RustProxy is running.", + "RustProxy is installed and serving this page. This does not verify an upstream application.", + "The administrator can configure a domain and backend or publish a local web service.", + "Ready", "Not checked", "ok", "unknown"), + ("placeholder", "Site placeholder", + "This address is displaying a RustProxy placeholder instead of application content.", + "Check the address or contact the administrator for information about this service.", + "Page served", "Not checked", "ok", "unknown"), +] + + def main() -> None: ROOT.mkdir(parents=True, exist_ok=True) for entry in STATUSES: path = ROOT / f"error_{entry[0]}.html" path.write_text(make_page(*entry), encoding="utf-8") - print(f"Generated {len(STATUSES)} offline RustProxy-branded status pages") + for variant, *entry in VARIANTS: + (ROOT / f"{variant}.html").write_text(make_page(None, *entry, variant=variant), encoding="utf-8") + print(f"Generated {len(STATUSES) + len(VARIANTS)} offline RustProxy-branded pages") if __name__ == "__main__": diff --git a/src/admin/openapi.json b/src/admin/openapi.json index 73b3506..bbcd61a 100644 --- a/src/admin/openapi.json +++ b/src/admin/openapi.json @@ -3133,10 +3133,12 @@ "empty", "html", "builtin", - "cloudflare" + "cloudflare", + "cloudflare_welcome", + "cloudflare_placeholder" ], "default": "welcome", - "description": "Optional offline Cloudflare-style page uses a pre-generated static HTML template with inline CSS; no runtime file reads or third-party requests. Existing built-in and custom HTML options are unchanged. Unsupported local statuses fall back to the normal built-in HTML." + "description": "Offline styles: cloudflare selects a status-specific template (200 or supported 4xx/5xx), cloudflare_welcome selects the congratulations page, and cloudflare_placeholder selects the placeholder. All use embedded HTML/CSS with no runtime file reads or third-party requests. HTTP status is independent of the welcome/placeholder design. Unsupported status-specific templates fall back to built-in HTML. Existing kinds remain unchanged." }, "status": { "type": "integer", diff --git a/src/admin/web/cf_page/README.md b/src/admin/web/cf_page/README.md index 3e1f49a..8475576 100644 --- a/src/admin/web/cf_page/README.md +++ b/src/admin/web/cf_page/README.md @@ -1,12 +1,12 @@ # Pre-generated Cloudflare-style pages -These `error_*.html` files are static, self-contained, English-language HTML/CSS pages. They were prepared for RustProxy 0.42.3, using the classic three-stage diagnostic layout of the open-source [cloudflare-error-page](https://github.com/donlon/cloudflare-error-page) project (Anthony Donlon, MIT license). They are adapted and branded for RustProxy with a large "RP" gateway symbol, a gray status band and compact two-column help: no Cloudflare logo, hyperlinks, generated Ray ID, service claims, telemetry or remote assets. The short footer reads "Performance & security by RustProxy". +These `error_*.html`, `welcome.html` and `placeholder.html` files are static, self-contained, English-language HTML/CSS pages. They were prepared for RustProxy 0.42.3, using the classic three-stage diagnostic layout of the open-source [cloudflare-error-page](https://github.com/donlon/cloudflare-error-page) project (Anthony Donlon, MIT license). They are adapted and branded for RustProxy with the exact RustProxy dashboard `r/p` brand mark and matching typography, border, dimensions and colors, a gray status band and compact two-column help: no Cloudflare logo, hyperlinks, generated Ray ID, service claims, telemetry or remote assets. The short footer reads "Powered by RustProxy". The status appears once in the heading; HTTP 200 is a success and HTTP 204 has no HTML body. Welcome and placeholder variants do not hard-code a status. - Each template lives in this directory in the source tree; `scripts/generate_cf_pages.py` regenerates them deterministically. - `src/pages/mod.rs` selects the file for the configured HTTP code through the **same `include_str!` pattern used by the existing RustProxy `error_*.html` pages**. - There is **no file I/O on public HTTP requests**, static-file mounting, template engine, JavaScript or external stylesheet. - The browser receives `text/html; charset=utf-8`, `Cache-Control: no-store` and the correct HTTP status; status 401 keeps `WWW-Authenticate` through existing page replacement logic. - This directory is not a public document root and these templates are not routed through the admin file server. -- Existing/default error pages remain unchanged unless the `cloudflare` page kind is explicitly selected. +- Existing/default error pages remain unchanged unless `cloudflare`, `cloudflare_welcome` or `cloudflare_placeholder` is explicitly selected. Before distributing modified templates, review the upstream project's [MIT license](https://github.com/donlon/cloudflare-error-page/blob/main/LICENSE.txt) and its trademark disclaimer. The pages here are an independent RustProxy-branded adaptation, not Cloudflare's official error pages. diff --git a/src/admin/web/cf_page/error_200.html b/src/admin/web/cf_page/error_200.html index 027b780..7902c2f 100644 --- a/src/admin/web/cf_page/error_200.html +++ b/src/admin/web/cf_page/error_200.html @@ -1,387 +1,66 @@ - - - - - Error 200: Service ready | RustProxy - + + + +Service ready | HTTP 200 | RustProxy + - - -
-

Service ready Error 200

-

Error code 200

-
-
-
-
-
-

You

-

Browser

-

Working

-
- -
-
-

Gateway

-

RustProxy

-

Working

-
- -
-
-

Origin

-

Host

-

Not checked

-
-
-
-
-
-
-

What happened?

-

RustProxy received and handled the request.

-
-
-

What can I do?

-

You can continue to the requested service.

-
-
-
RustProxyPerformance & security by - RustProxy
-
+ +

Request status

Service ready HTTP 200

+
+

You

Browser

Request sent

+ +
r/p

Gateway

RustProxy

Working

+ +

Origin

Host

Not checked

+
+
+

About this page

RustProxy received and handled the request.

+

What comes next?

No further action is required for this response.

+
Powered by RustProxy
+
- - \ No newline at end of file + diff --git a/src/admin/web/cf_page/error_400.html b/src/admin/web/cf_page/error_400.html index c26f4a9..097b9bc 100644 --- a/src/admin/web/cf_page/error_400.html +++ b/src/admin/web/cf_page/error_400.html @@ -1,387 +1,66 @@ - - - - - Error 400: Bad request | RustProxy - + + + +Bad request | Error 400 | RustProxy + - - -
-

Bad request Error 400

-

Error code 400

-
-
-
-
-
-

You

-

Browser

-

Working

-
- -
-
-

Gateway

-

RustProxy

-

Request rejected

-
- -
-
-

Origin

-

Host

-

Not contacted

-
-
-
-
-
-
-

What happened?

-

The request was malformed or could not be understood.

-
-
-

What can I do?

-

Check the request and try again.

-
-
-
RustProxyPerformance & security by - RustProxy
-
+ +

Request status

Bad request Error 400

+
+

You

Browser

Request sent

+ +
r/p

Gateway

RustProxy

Request rejected

+ +

Origin

Host

Not contacted

+
+
+

What happened?

The request was malformed or could not be understood.

+

What can I do?

Check the request and try again.

+
Powered by RustProxy
+
- - \ No newline at end of file + diff --git a/src/admin/web/cf_page/error_401.html b/src/admin/web/cf_page/error_401.html index 0ab3bf9..ba9b803 100644 --- a/src/admin/web/cf_page/error_401.html +++ b/src/admin/web/cf_page/error_401.html @@ -1,387 +1,66 @@ - - - - - Error 401: Authentication required | RustProxy - + + + +Authentication required | Error 401 | RustProxy + - - -
-

Authentication required Error 401

-

Error code 401

-
-
-
-
-
-

You

-

Browser

-

Working

-
- -
-
-

Gateway

-

RustProxy

-

Authentication required

-
- -
-
-

Origin

-

Host

-

Not contacted

-
-
-
-
-
-
-

What happened?

-

This resource requires valid credentials.

-
-
-

What can I do?

-

Sign in with an authorized account and retry.

-
-
-
RustProxyPerformance & security by - RustProxy
-
+ +

Request status

Authentication required Error 401

+
+

You

Browser

Request sent

+ +
r/p

Gateway

RustProxy

Authentication required

+ +

Origin

Host

Not contacted

+
+
+

What happened?

This resource requires valid credentials.

+

What can I do?

Sign in with an authorized account and retry.

+
Powered by RustProxy
+
- - \ No newline at end of file + diff --git a/src/admin/web/cf_page/error_403.html b/src/admin/web/cf_page/error_403.html index fd0e819..7c95e28 100644 --- a/src/admin/web/cf_page/error_403.html +++ b/src/admin/web/cf_page/error_403.html @@ -1,387 +1,66 @@ - - - - - Error 403: Access forbidden | RustProxy - + + + +Access forbidden | Error 403 | RustProxy + - - -
-

Access forbidden Error 403

-

Error code 403

-
-
-
-
-
-

You

-

Browser

-

Working

-
- -
-
-

Gateway

-

RustProxy

-

Access denied

-
- -
-
-

Origin

-

Host

-

Not contacted

-
-
-
-
-
-
-

What happened?

-

Access to the requested resource is not permitted.

-
-
-

What can I do?

-

Contact the website administrator if you believe this is an error.

-
-
-
RustProxyPerformance & security by - RustProxy
-
+ +

Request status

Access forbidden Error 403

+
+

You

Browser

Request sent

+ +
r/p

Gateway

RustProxy

Access denied

+ +

Origin

Host

Not contacted

+
+
+

What happened?

Access to the requested resource is not permitted.

+

What can I do?

Contact the website administrator if you believe this is an error.

+
Powered by RustProxy
+
- - \ No newline at end of file + diff --git a/src/admin/web/cf_page/error_404.html b/src/admin/web/cf_page/error_404.html index 4ee1b71..8a8faa7 100644 --- a/src/admin/web/cf_page/error_404.html +++ b/src/admin/web/cf_page/error_404.html @@ -1,387 +1,66 @@ - - - - - Error 404: Page not found | RustProxy - + + + +Page not found | Error 404 | RustProxy + - - -
-

Page not found Error 404

-

Error code 404

-
-
-
-
-
-

You

-

Browser

-

Working

-
- -
-
-

Gateway

-

RustProxy

-

Not found

-
- -
-
-

Origin

-

Host

-

Not confirmed

-
-
-
-
-
-
-

What happened?

-

The requested resource could not be found.

-
-
-

What can I do?

-

Check the address or return to the website homepage.

-
-
-
RustProxyPerformance & security by - RustProxy
-
+ +

Request status

Page not found Error 404

+
+

You

Browser

Request sent

+ +
r/p

Gateway

RustProxy

Not found

+ +

Origin

Host

Not confirmed

+
+
+

What happened?

The requested resource could not be found.

+

What can I do?

Check the address or return to the website homepage.

+
Powered by RustProxy
+
- - \ No newline at end of file + diff --git a/src/admin/web/cf_page/error_408.html b/src/admin/web/cf_page/error_408.html index 7cd4508..3fa5379 100644 --- a/src/admin/web/cf_page/error_408.html +++ b/src/admin/web/cf_page/error_408.html @@ -1,387 +1,66 @@ - - - - - Error 408: Request timeout | RustProxy - + + + +Request timeout | Error 408 | RustProxy + - - -
-

Request timeout Error 408

-

Error code 408

-
-
-
-
-
-

You

-

Browser

-

Working

-
- -
-
-

Gateway

-

RustProxy

-

Timed out

-
- -
-
-

Origin

-

Host

-

Not confirmed

-
-
-
-
-
-
-

What happened?

-

The request took too long to complete.

-
-
-

What can I do?

-

Try again when your connection is stable.

-
-
-
RustProxyPerformance & security by - RustProxy
-
+ +

Request status

Request timeout Error 408

+
+

You

Browser

Request sent

+ +
r/p

Gateway

RustProxy

Timed out

+ +

Origin

Host

Not confirmed

+
+
+

What happened?

The request took too long to complete.

+

What can I do?

Try again when your connection is stable.

+
Powered by RustProxy
+
- - \ No newline at end of file + diff --git a/src/admin/web/cf_page/error_410.html b/src/admin/web/cf_page/error_410.html index 678dee1..be6e675 100644 --- a/src/admin/web/cf_page/error_410.html +++ b/src/admin/web/cf_page/error_410.html @@ -1,387 +1,66 @@ - - - - - Error 410: Resource gone | RustProxy - + + + +Resource gone | Error 410 | RustProxy + - - -
-

Resource gone Error 410

-

Error code 410

-
-
-
-
-
-

You

-

Browser

-

Working

-
- -
-
-

Gateway

-

RustProxy

-

No longer available

-
- -
-
-

Origin

-

Host

-

Not contacted

-
-
-
-
-
-
-

What happened?

-

The requested resource is no longer available.

-
-
-

What can I do?

-

Update any saved links to this resource.

-
-
-
RustProxyPerformance & security by - RustProxy
-
+ +

Request status

Resource gone Error 410

+
+

You

Browser

Request sent

+ +
r/p

Gateway

RustProxy

No longer available

+ +

Origin

Host

Not contacted

+
+
+

What happened?

The requested resource is no longer available.

+

What can I do?

Update any saved links to this resource.

+
Powered by RustProxy
+
- - \ No newline at end of file + diff --git a/src/admin/web/cf_page/error_413.html b/src/admin/web/cf_page/error_413.html index 20beca3..53aa6a0 100644 --- a/src/admin/web/cf_page/error_413.html +++ b/src/admin/web/cf_page/error_413.html @@ -1,387 +1,66 @@ - - - - - Error 413: Content too large | RustProxy - + + + +Content too large | Error 413 | RustProxy + - - -
-

Content too large Error 413

-

Error code 413

-
-
-
-
-
-

You

-

Browser

-

Working

-
- -
-
-

Gateway

-

RustProxy

-

Request rejected

-
- -
-
-

Origin

-

Host

-

Not contacted

-
-
-
-
-
-
-

What happened?

-

The request body exceeds the allowed size.

-
-
-

What can I do?

-

Reduce the size of the request and try again.

-
-
-
RustProxyPerformance & security by - RustProxy
-
+ +

Request status

Content too large Error 413

+
+

You

Browser

Request sent

+ +
r/p

Gateway

RustProxy

Request rejected

+ +

Origin

Host

Not contacted

+
+
+

What happened?

The request body exceeds the allowed size.

+

What can I do?

Reduce the size of the request and try again.

+
Powered by RustProxy
+
- - \ No newline at end of file + diff --git a/src/admin/web/cf_page/error_429.html b/src/admin/web/cf_page/error_429.html index 7f6c701..c56efea 100644 --- a/src/admin/web/cf_page/error_429.html +++ b/src/admin/web/cf_page/error_429.html @@ -1,387 +1,66 @@ - - - - - Error 429: Too many requests | RustProxy - + + + +Too many requests | Error 429 | RustProxy + - - -
-

Too many requests Error 429

-

Error code 429

-
-
-
-
-
-

You

-

Browser

-

Working

-
- -
-
-

Gateway

-

RustProxy

-

Rate limited

-
- -
-
-

Origin

-

Host

-

Not contacted

-
-
-
-
-
-
-

What happened?

-

The request rate limit has been exceeded.

-
-
-

What can I do?

-

Wait a moment before trying again.

-
-
-
RustProxyPerformance & security by - RustProxy
-
+ +

Request status

Too many requests Error 429

+
+

You

Browser

Request sent

+ +
r/p

Gateway

RustProxy

Rate limited

+ +

Origin

Host

Not contacted

+
+
+

What happened?

The request rate limit has been exceeded.

+

What can I do?

Wait a moment before trying again.

+
Powered by RustProxy
+
- - \ No newline at end of file + diff --git a/src/admin/web/cf_page/error_500.html b/src/admin/web/cf_page/error_500.html index 3986783..aec24bc 100644 --- a/src/admin/web/cf_page/error_500.html +++ b/src/admin/web/cf_page/error_500.html @@ -1,387 +1,66 @@ - - - - - Error 500: Internal server error | RustProxy - + + + +Internal server error | Error 500 | RustProxy + - - -
-

Internal server error Error 500

-

Error code 500

-
-
-
-
-
-

You

-

Browser

-

Working

-
- -
-
-

Gateway

-

RustProxy

-

Error

-
- -
-
-

Origin

-

Host

-

Not confirmed

-
-
-
-
-
-
-

What happened?

-

An unexpected error occurred while processing this request.

-
-
-

What can I do?

-

Try again shortly. If the issue persists, contact the administrator.

-
-
-
RustProxyPerformance & security by - RustProxy
-
+ +

Request status

Internal server error Error 500

+
+

You

Browser

Request sent

+ +
r/p

Gateway

RustProxy

Error

+ +

Origin

Host

Not confirmed

+
+
+

What happened?

An unexpected error occurred while processing this request.

+

What can I do?

Try again shortly. If the issue persists, contact the administrator.

+
Powered by RustProxy
+
- - \ No newline at end of file + diff --git a/src/admin/web/cf_page/error_502.html b/src/admin/web/cf_page/error_502.html index 7dda61d..b6d953e 100644 --- a/src/admin/web/cf_page/error_502.html +++ b/src/admin/web/cf_page/error_502.html @@ -1,387 +1,66 @@ - - - - - Error 502: Bad gateway | RustProxy - + + + +Bad gateway | Error 502 | RustProxy + - - -
-

Bad gateway Error 502

-

Error code 502

-
-
-
-
-
-

You

-

Browser

-

Working

-
- -
-
-

Gateway

-

RustProxy

-

Working

-
- -
-
-

Origin

-

Host

-

Connection error

-
-
-
-
-
-
-

What happened?

-

The gateway could not obtain a valid response from the upstream service.

-
-
-

What can I do?

-

Try again in a few minutes. If the problem continues, contact the administrator.

-
-
-
RustProxyPerformance & security by - RustProxy
-
+ +

Request status

Bad gateway Error 502

+
+

You

Browser

Request sent

+ +
r/p

Gateway

RustProxy

Working

+ +

Origin

Host

Connection error

+
+
+

What happened?

The gateway could not obtain a valid response from the upstream service.

+

What can I do?

Try again in a few minutes. If the problem continues, contact the administrator.

+
Powered by RustProxy
+
- - \ No newline at end of file + diff --git a/src/admin/web/cf_page/error_503.html b/src/admin/web/cf_page/error_503.html index 6c6b7c9..5761195 100644 --- a/src/admin/web/cf_page/error_503.html +++ b/src/admin/web/cf_page/error_503.html @@ -1,387 +1,66 @@ - - - - - Error 503: Service unavailable | RustProxy - + + + +Service unavailable | Error 503 | RustProxy + - - -
-

Service unavailable Error 503

-

Error code 503

-
-
-
-
-
-

You

-

Browser

-

Working

-
- -
-
-

Gateway

-

RustProxy

-

Temporarily unavailable

-
- -
-
-

Origin

-

Host

-

Not confirmed

-
-
-
-
-
-
-

What happened?

-

The service is temporarily unable to handle this request.

-
-
-

What can I do?

-

Please try again in a few minutes.

-
-
-
RustProxyPerformance & security by - RustProxy
-
+ +

Request status

Service unavailable Error 503

+
+

You

Browser

Request sent

+ +
r/p

Gateway

RustProxy

Temporarily unavailable

+ +

Origin

Host

Not confirmed

+
+
+

What happened?

The service is temporarily unable to handle this request.

+

What can I do?

Please try again in a few minutes.

+
Powered by RustProxy
+
- - \ No newline at end of file + diff --git a/src/admin/web/cf_page/error_504.html b/src/admin/web/cf_page/error_504.html index 1eb0880..cbbfde6 100644 --- a/src/admin/web/cf_page/error_504.html +++ b/src/admin/web/cf_page/error_504.html @@ -1,387 +1,66 @@ - - - - - Error 504: Gateway timeout | RustProxy - + + + +Gateway timeout | Error 504 | RustProxy + - - -
-

Gateway timeout Error 504

-

Error code 504

-
-
-
-
-
-

You

-

Browser

-

Working

-
- -
-
-

Gateway

-

RustProxy

-

Working

-
- -
-
-

Origin

-

Host

-

Timed out

-
-
-
-
-
-
-

What happened?

-

The upstream service did not respond in time.

-
-
-

What can I do?

-

Try again shortly. If the problem continues, contact the administrator.

-
-
-
RustProxyPerformance & security by - RustProxy
-
+ +

Request status

Gateway timeout Error 504

+
+

You

Browser

Request sent

+ +
r/p

Gateway

RustProxy

Working

+ +

Origin

Host

Timed out

+
+
+

What happened?

The upstream service did not respond in time.

+

What can I do?

Try again shortly. If the problem continues, contact the administrator.

+
Powered by RustProxy
+
- - \ No newline at end of file + diff --git a/src/admin/web/cf_page/placeholder.html b/src/admin/web/cf_page/placeholder.html new file mode 100644 index 0000000..b763d14 --- /dev/null +++ b/src/admin/web/cf_page/placeholder.html @@ -0,0 +1,66 @@ + + + + + + +Site placeholder | RustProxy + + + +

Placeholder

Site placeholder

+
+

You

Browser

Request sent

+ +
r/p

Gateway

RustProxy

Page served

+ +

Origin

Host

Not checked

+
+
+

About this page

This address is displaying a RustProxy placeholder instead of application content.

+

What comes next?

Check the address or contact the administrator for information about this service.

+
Powered by RustProxy
+
+ + diff --git a/src/admin/web/cf_page/welcome.html b/src/admin/web/cf_page/welcome.html new file mode 100644 index 0000000..da39673 --- /dev/null +++ b/src/admin/web/cf_page/welcome.html @@ -0,0 +1,66 @@ + + + + + + +Congratulations! RustProxy is running. | RustProxy + + + +

Welcome

Congratulations! RustProxy is running.

+
+

You

Browser

Request sent

+ +
r/p

Gateway

RustProxy

Ready

+ +

Origin

Host

Not checked

+
+
+

About this page

RustProxy is installed and serving this page. This does not verify an upstream application.

+

What comes next?

The administrator can configure a domain and backend or publish a local web service.

+
Powered by RustProxy
+
+ + diff --git a/src/admin/web/css/10-base.css b/src/admin/web/css/10-base.css index b3923fd..33926d0 100644 --- a/src/admin/web/css/10-base.css +++ b/src/admin/web/css/10-base.css @@ -863,11 +863,8 @@ progress::-moz-progress-bar { flex-wrap: wrap; gap: 9px 13px; min-width: 0; - padding: 10px 12px; + padding: 0; margin: 8px 0 14px; - background: var(--panel2); - border: 1px solid var(--line); - border-radius: var(--rp-radius-surface, 5px); } .page-bulk-actions .page-bulk-switch-label { @@ -883,11 +880,6 @@ progress::-moz-progress-bar { overflow-wrap: anywhere; } -.page-bulk-actions .fine { - flex: 1 1 220px; - min-width: 0; - margin: 0; -} .pages-errors { margin: 12px 0; diff --git a/src/admin/web/host404.js b/src/admin/web/host404.js index 498817f..0006d24 100644 --- a/src/admin/web/host404.js +++ b/src/admin/web/host404.js @@ -87,7 +87,7 @@ const actions = el("div", undefined, "entity-actions"); actions.append(action(t("edit"), () => { window.rustProxyDrafts.prepare(); load(structuredClone(item)); }), action(t("copyEntry"), () => { window.rustProxyDrafts.prepare(); const copy = structuredClone(item); copy.id = ""; copy.name = ""; copy.frontend = { ...(copy.frontend || {}), hosts: [] }; copy.certificate_id = null; load(copy); }), action(t("remove"), async () => { if (busy || !(await appConfirm(t("confirmDelete"), { danger: true }))) return; const next = (envelope.config.not_found_hosts || []).filter(value => value.id !== item.id); if (await saveSection("not-found-hosts", next)) { if (editing === item.id) dialog.close(); render(); } })); head.append(actions); card.append(head); const flow = el("div", undefined, "redirect-flow"), from = el("div", undefined, "redirect-flow-from"), to = el("div", undefined, "redirect-flow-to"); for (const host of item.frontend?.hosts || []) from.append(el("span", host, "redirect-host-chip")); - to.append(el("span", `${item.page?.status ?? 404} ${STATUS_NAMES[item.page?.status ?? 404] || ""}`.trim(), "redirect-target"), el("span", t(`notfoundMode${(item.page?.kind || "welcome").replace(/^./, c => c.toUpperCase())}`), "redirect-target-more")); + to.append(el("span", `${item.page?.status ?? 404} ${STATUS_NAMES[item.page?.status ?? 404] || ""}`.trim(), "redirect-target"), el("span", t(`notfoundMode${(item.page?.kind || "welcome").replace(/(^|_)([a-z])/g, (_, prefix, c) => c.toUpperCase())}`), "redirect-target-more")); flow.append(from, el("span", "→", "redirect-flow-arrow"), to); card.append(flow); const meta = el("div", undefined, "redirect-meta"); for (const [k, v] of [["redirectListeners", (item.frontend?.listener_ids || []).join(", ") || "-"], ["vhCertificate", item.certificate_id || t("vhCertificateDefault")]]) { const node = el("span", undefined, "redirect-meta-item"); node.append(el("span", t(k)), el("b", v)); meta.append(node); } diff --git a/src/admin/web/index.html b/src/admin/web/index.html index b440070..e40a0e4 100644 --- a/src/admin/web/index.html +++ b/src/admin/web/index.html @@ -5461,6 +5461,8 @@ log_errors = On + + diff --git a/src/admin/web/management.js b/src/admin/web/management.js index f89b3b0..6b133f4 100644 --- a/src/admin/web/management.js +++ b/src/admin/web/management.js @@ -9,7 +9,7 @@ const row = el("div", undefined, "page-editor"), heading = label("strong", key, "page-label"); row.append(heading); const mode = el("select"), status = el("select"), html = el("textarea"), file = el("input"); mode.setAttribute("aria-label", t(key)); mode.className = "page-mode"; - mode.append(option("", "pageInherit"), option("welcome", "pageWelcome"), option("builtin", "pageBuiltin"), option("cloudflare", "pageCloudflare"), option("empty", "pageEmpty"), option("html", "pageHtml")); + mode.append(option("", "pageInherit"), option("welcome", "pageWelcome"), option("builtin", "pageBuiltin"), option("cloudflare", "pageCloudflare"), option("cloudflare_welcome", "pageCloudflareWelcome"), option("cloudflare_placeholder", "pageCloudflarePlaceholder"), option("empty", "pageEmpty"), option("html", "pageHtml")); mode.value = value?.kind || ""; status.className = "page-status"; status.setAttribute("aria-label", t("pageStatus")); status.append(option("", "pageOriginalStatus")); @@ -17,7 +17,7 @@ status.value = value?.status ?? ""; html.value = value?.html || ""; html.rows = 5; html.maxLength = 32768; html.spellcheck = false; html.className = "page-html"; html.setAttribute("aria-label", t("pageHtmlSource")); file.type = "file"; file.accept = ".html,.htm,text/html,text/plain"; file.setAttribute("aria-label", t("pageUploadHtml")); const source = el("div", undefined, "page-source"); source.append(label("span", "pageUploadHtml", "fine"), file, html); - function sync() { status.disabled = !mode.value; source.hidden = mode.value !== "html"; if (status.value === "204" && mode.value !== "empty") status.value = ""; } + function sync() { if (mode.value && status.value === "204") mode.value = "empty"; status.disabled = !mode.value; source.hidden = mode.value !== "html"; } for (const event of ["change", "input"]) { mode.addEventListener(event, sync); status.addEventListener(event, sync); } file.addEventListener("change", async () => { try { const chosen = file.files[0]; if (!chosen) return; if (chosen.size > 32768) throw new Error(t("pageTooLarge")); html.value = await chosen.text(); html.dispatchEvent(new Event("input", { bubbles: true })); } catch (error) { toast(error.message, true); } finally { file.value = ""; } }); row.append(mode, status, source); parent.append(row); sync(); @@ -27,9 +27,16 @@ if (!kind) status.value = ""; mode.dispatchEvent(new Event("change", { bubbles: true })); } + const styled = () => mode.value === "cloudflare" || mode.value === "cloudflare_welcome" || mode.value === "cloudflare_placeholder"; + const bodyless = () => mode.value === "empty" && status.value === "204"; return { - row, setCloudflare: () => setMode("cloudflare"), reset: () => setMode(""), - isCloudflare: () => mode.value === "cloudflare", + row, setCloudflare: () => { + if (bodyless() || styled()) return; + if (mode.value === "welcome" && key !== "customErrorPages") { + setMode(key === "pageUnknownHost" || key === "pageMissingPath" ? "cloudflare_placeholder" : "cloudflare_welcome"); + } else setMode("cloudflare"); + }, reset: () => setMode(""), + isCloudflare: () => styled() || bodyless(), read() { if (!mode.value) return null; const markup = mode.value === "html" ? html.value : ""; if (new TextEncoder().encode(markup).length > 32768) throw new Error(t("pageTooLarge")); return { kind: mode.value, status: status.value ? Number(status.value) : null, html: markup }; } }; } @@ -43,7 +50,7 @@ read() { return Object.fromEntries([...rows].map(([code, editor]) => [code, editor.read()]).filter(([, page]) => page)); } }; } - function bulkCloudflareSwitch(parent, apply, helpKey) { + function bulkCloudflareSwitch(parent, apply) { const wrapper = el("div", undefined, "page-bulk-actions"); const control = el("label", undefined, "check page-bulk-switch-label"); const toggle = document.createElement("input"); @@ -51,7 +58,7 @@ toggle.className = "switch"; control.append(toggle, label("span", "pageCloudflareAll")); toggle.addEventListener("change", () => apply(toggle.checked)); - wrapper.append(control, label("span", helpKey, "fine")); + wrapper.append(control); parent.append(wrapper); return toggle; } diff --git a/src/not_found/tests.rs b/src/not_found/tests.rs index 519f794..7e21c2d 100644 --- a/src/not_found/tests.rs +++ b/src/not_found/tests.rs @@ -47,6 +47,16 @@ mod tests { .is_err()); } + #[test] + fn styled_welcome_and_placeholder_keep_404_host_error_status_restrictions() { + for kind in [crate::pages::Kind::CloudflareWelcome, crate::pages::Kind::CloudflarePlaceholder] { + assert!(host(kind, 404).validate().is_ok()); + assert!(host(kind, 503).validate().is_ok()); + assert!(host(kind, 200).validate().is_err()); + assert!(host(kind, 204).validate().is_err()); + } + } + #[test] fn application_style_hosts_require_a_bundled_template() { for status in crate::pages::BUILTIN_ERROR_CODES { diff --git a/src/pages/mod.rs b/src/pages/mod.rs index fbba524..90fed3e 100644 --- a/src/pages/mod.rs +++ b/src/pages/mod.rs @@ -88,6 +88,8 @@ pub enum Kind { Html, Builtin, Cloudflare, + CloudflareWelcome, + CloudflarePlaceholder, } #[derive(Debug, Clone, Default, Serialize, Deserialize)] #[serde(default, deny_unknown_fields)] @@ -183,6 +185,8 @@ impl Page { Kind::Html => self.html.clone(), Kind::Welcome => include_str!("../admin/web/demo.html").to_owned(), Kind::Builtin => builtin_application_page(status), + Kind::CloudflareWelcome => include_str!("../admin/web/cf_page/welcome.html").to_owned(), + Kind::CloudflarePlaceholder => include_str!("../admin/web/cf_page/placeholder.html").to_owned(), Kind::Cloudflare => cloudflare_style_page(status) .map(str::to_owned) .unwrap_or_else(|| builtin_application_page(status)), diff --git a/src/pages/tests.rs b/src/pages/tests.rs index 5e78e98..cc6208d 100644 --- a/src/pages/tests.rs +++ b/src/pages/tests.rs @@ -64,13 +64,18 @@ mod tests { ] { let status = StatusCode::from_u16(code).unwrap(); let template = cloudflare_style_page(status).expect("missing Cloudflare template"); - assert!( - template.contains(&format!("Error {code}")), - "{code}" - ); + let label = if code == 200 { "HTTP 200".to_owned() } else { format!("Error {code}") }; + assert!(template.contains(&format!("{label}")), "{code}"); + assert!(!template.contains("Error code"), "{code}"); + if code == 200 { + assert!(!template.contains("Error 200")); + assert!(!template.contains("What happened?")); + } + assert!(template.contains("class=\"brand-mark\""), "{code}"); + assert!(!template.contains(">RP"), "{code}"); assert!(template.contains("class=\"diagnostics-band\""), "{code}"); assert!( - template.contains("Performance & security by RustProxy"), + template.contains("Powered by RustProxy"), "{code}" ); assert!(!template.contains("Response generated by"), "{code}"); @@ -121,6 +126,48 @@ mod tests { assert!(std::str::from_utf8(&body).unwrap().contains("418 - ")); } + #[tokio::test] + async fn cloudflare_welcome_and_placeholder_are_independent_of_http_status() { + for (kind, name, heading) in [ + (Kind::CloudflareWelcome, "cloudflare_welcome", "Congratulations! RustProxy is running."), + (Kind::CloudflarePlaceholder, "cloudflare_placeholder", "Site placeholder"), + ] { + for status in [StatusCode::OK, StatusCode::NOT_FOUND, StatusCode::SERVICE_UNAVAILABLE] { + let page = Page { kind, status: Some(status.as_u16()), html: String::new() }; + page.validate().unwrap(); + page.validate_local_response().unwrap(); + let json = serde_json::to_value(&page).unwrap(); + assert_eq!(json["kind"].as_str(), Some(name)); + let decoded: Page = serde_json::from_value(json).unwrap(); + let response = decoded.render(StatusCode::BAD_GATEWAY); + assert_eq!(response.status(), status); + assert_eq!(response.headers()["cache-control"], "no-store"); + assert_eq!(response.headers()["x-content-type-options"], "nosniff"); + let bytes = response.into_body().collect().await.unwrap().to_bytes(); + let html = std::str::from_utf8(&bytes).unwrap(); + assert!(html.contains(heading)); + assert!(html.contains("class=\"brand-mark\"")); + assert!(!html.contains("Error code")); + assert!(!html.contains("class=\"status-code\"")); + } + } + } + + #[tokio::test] + async fn no_content_never_renders_a_styled_page() { + assert!(cloudflare_style_page(StatusCode::NO_CONTENT).is_none()); + for kind in [Kind::Cloudflare, Kind::CloudflareWelcome, Kind::CloudflarePlaceholder, Kind::Empty] { + let mut page = Page { kind, status: Some(204), html: String::new() }; + assert_eq!(page.validate().is_ok(), matches!(kind, Kind::Empty)); + assert_eq!(page.validate_local_response().is_ok(), matches!(kind, Kind::Empty)); + page.status = None; + let response = page.render(StatusCode::NO_CONTENT); + assert_eq!(response.status(), StatusCode::NO_CONTENT); + assert!(!response.headers().contains_key("content-length")); + assert!(response.into_body().collect().await.unwrap().to_bytes().is_empty()); + } + } + #[tokio::test] async fn cloudflare_error_replacement_preserves_challenge_and_no_store() { let mut response = Response::new(Body::from("old"));