v0.42.2
This commit is contained in:
1 parent
aa0a271a1c
commit
f38a2b9e5e
38 files changed
+1098
-160
No files matched your search
@@ -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.
|
||||
+110
@@ -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.
|
||||
+1
-1
@@ -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.
|
||||
|
||||

|
||||
|
||||
+1
-1
@@ -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
|
||||
|
||||
|
||||
@@ -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.
|
||||
|
||||
+8
-4
@@ -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.
|
||||
|
||||
|
||||
Reference in new issue
Block a user