Refactor nginx to path-based domain model with config migration
Replace the legacy top-level management key with a unified paths-based model. Each domain now contains a paths map where each entry defines its own backend, auth, headers, and flags (is_management, is_websocket). - Add _migrate_config() to auto-migrate legacy formats on first load - Remove set_management_proxy() and POST_NGINX_MANAGEMENT endpoint - Update server_block.conf template to iterate paths with per-location auth - Update daemon handler, API blueprint, state collector, and install script - Add server config generation tests for paths, WebSocket, auth inheritance - Update frontend proxy page to display per-path rows with flags
This commit is contained in:
+20
-27
@@ -715,13 +715,15 @@ Write the global nginx SSL snippet configuration.
|
||||
GET /api/proxy/domains
|
||||
```
|
||||
|
||||
Return all configured proxy domains.
|
||||
Return all configured proxy domains. The response is flattened by path — each path within a domain produces a separate entry.
|
||||
|
||||
**Response:**
|
||||
|
||||
| Field | Type | Description |
|
||||
|-------|------|-------------|
|
||||
| `data` | `[object, ...]` | Array of domain configuration objects |
|
||||
| `data` | `[object, ...]` | Array of path-level domain configuration objects |
|
||||
|
||||
Each entry contains `domain` (string), `path` (string), `backend` (object with `host`, `port`, `proto`), `online` (boolean), `force_ssl` (boolean), and optionally `is_management` or `is_websocket` flags.
|
||||
|
||||
---
|
||||
|
||||
@@ -731,9 +733,18 @@ Return all configured proxy domains.
|
||||
POST /api/proxy/domains
|
||||
```
|
||||
|
||||
Add a new reverse proxy domain.
|
||||
Add a new reverse proxy domain. Accepts two modes:
|
||||
|
||||
**Request Body:**
|
||||
**Paths mode (preferred):**
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
|-------|------|----------|-------------|
|
||||
| `domain` | `string` | Yes | Domain name to proxy |
|
||||
| `paths` | `object` | Yes | Path-to-config map. Each path entry must have a `backend` key with `host`, `port`, `proto`. |
|
||||
| `cert` | `string` | No | Certificate type |
|
||||
| `force_ssl` | `boolean` | No | HTTPS redirect flag (default `true`) |
|
||||
|
||||
**Legacy mode (backward compatible):**
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
|-------|------|----------|-------------|
|
||||
@@ -741,7 +752,7 @@ Add a new reverse proxy domain.
|
||||
| `backend_host` | `string` | Yes | Backend server IP or hostname |
|
||||
| `backend_port` | `number` | Yes | Backend server port |
|
||||
| `backend_proto` | `string` | No | Backend protocol (`"http"` or `"https"`); defaults to `"http"` |
|
||||
| `cert` | `string` | No | Certificate domain |
|
||||
| `cert` | `string` | No | Certificate type |
|
||||
| `extra_headers` | `object` | No | Extra proxy headers |
|
||||
|
||||
**Response (`data`):**
|
||||
@@ -774,9 +785,9 @@ Returns HTTP `404` if the domain is not configured.
|
||||
PUT /api/proxy/domains/<domain>
|
||||
```
|
||||
|
||||
Update one or more fields of an existing domain entry. Only fields present in the body are modified.
|
||||
Update one or more fields of an existing domain entry. Only fields present in the body are modified. Supports both domain-level keys (`paths`, `force_ssl`, `cert`, `auth`) and path-level shorthand (`backend`, `headers` for the root path).
|
||||
|
||||
**Request Body:** Any subset of (`backend_host`, `backend_port`, `backend_proto`, `cert`, `extra_headers`).
|
||||
**Request Body:** Any subset of (`paths`, `backend`, `backend_host`, `backend_port`, `backend_proto`, `cert`, `extra_headers`, `force_ssl`, `auth`).
|
||||
|
||||
**Response (`data`):**
|
||||
|
||||
@@ -837,27 +848,9 @@ Run `nginx -t` against the generated configuration without reloading.
|
||||
|
||||
**Error (invalid):** HTTP `400` with standard `{"ok": false, "error": "<nginx output>"}` response.
|
||||
|
||||
### Management
|
||||
### Management Proxy
|
||||
|
||||
#### Configure Management WebUI Proxy
|
||||
|
||||
```
|
||||
POST /api/proxy/management
|
||||
```
|
||||
|
||||
Configure the nginx proxy block for the management WebUI itself, including optional HTTP basic authentication.
|
||||
|
||||
**Request Body:**
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
|-------|------|----------|-------------|
|
||||
| `domain` | `string` | Yes | Management domain (e.g., `"myhost.local"`) |
|
||||
| `flask_host` | `string` | No | Flask app bind host; defaults to `"127.0.0.1"` |
|
||||
| `flask_port` | `number` | No | Flask app bind port; defaults to `9090` |
|
||||
| `auth_user` | `string` | No | Username for basic auth |
|
||||
| `auth_pass` | `string` | No | Password for basic auth |
|
||||
|
||||
**Response:** `data` is `null` on success.
|
||||
>The legacy `POST /api/proxy/management` endpoint has been removed. The management WebUI proxy is now configured as a regular domain entry with `is_management: true` on the root path and `is_websocket: true` on the `/ws` path. Use the standard domain add/update endpoints to configure it.
|
||||
|
||||
---
|
||||
|
||||
|
||||
Reference in New Issue
Block a user