mirror of
https://github.com/NginxProxyManager/nginx-proxy-manager.git
synced 2026-09-24 19:30:27 +01:00
Nginx Proxy Manager had no way to inspect application or nginx logs from the web UI - admins had to shell into the container or read `docker logs`. This adds an admin-only Logs page that can tail: - the backend application log, now also mirrored to /data/logs/backend.log (in addition to stdout) and rotated by the logrotate timer that already runs every 2 days - the Let's Encrypt/certbot log, which certbot already writes to /data/logs/letsencrypt.log via its existing --logs-dir flag - per-host nginx access/error logs (proxy, redirection, 404 and stream hosts), with the file path always resolved server-side from a validated host_type enum + numeric host_id, never from client input Reads use a reverse chunked scan (64KB chunks, capped at 5MB scanned per request) instead of loading whole files into memory, and the frontend polls every 5s only while the tab is focused and "Live" is on, so this stays cheap on both CPU and memory. No new runtime dependencies were added on either side. Purely additive: two new admin-only endpoints (GET /api/logs/sources, GET /api/logs/tail), no existing behaviour changed.
101 lines
2.0 KiB
JSON
101 lines
2.0 KiB
JSON
{
|
|
"operationId": "getLogTail",
|
|
"summary": "Get the last N lines of a log source",
|
|
"tags": ["logs"],
|
|
"security": [
|
|
{
|
|
"bearerAuth": ["admin"]
|
|
}
|
|
],
|
|
"parameters": [
|
|
{
|
|
"in": "query",
|
|
"name": "type",
|
|
"required": true,
|
|
"description": "Which log source to read",
|
|
"schema": {
|
|
"type": "string",
|
|
"enum": ["system", "letsencrypt", "host"]
|
|
}
|
|
},
|
|
{
|
|
"in": "query",
|
|
"name": "host_type",
|
|
"description": "Required when type=host",
|
|
"schema": {
|
|
"type": "string",
|
|
"enum": ["proxy", "redirection", "dead", "stream"]
|
|
}
|
|
},
|
|
{
|
|
"in": "query",
|
|
"name": "host_id",
|
|
"description": "Required when type=host",
|
|
"schema": {
|
|
"type": "integer",
|
|
"minimum": 1
|
|
}
|
|
},
|
|
{
|
|
"in": "query",
|
|
"name": "channel",
|
|
"description": "Required when type=host - which log file to read (not to be confused with host_type=stream)",
|
|
"schema": {
|
|
"type": "string",
|
|
"enum": ["access", "error"]
|
|
}
|
|
},
|
|
{
|
|
"in": "query",
|
|
"name": "lines",
|
|
"description": "Number of lines to return from the end of the file",
|
|
"schema": {
|
|
"type": "integer",
|
|
"minimum": 1,
|
|
"maximum": 1000,
|
|
"default": 200
|
|
}
|
|
},
|
|
{
|
|
"in": "query",
|
|
"name": "level",
|
|
"description": "Only applicable to type=system",
|
|
"schema": {
|
|
"type": "string",
|
|
"enum": ["INFO", "WARN", "ERROR", "DEBUG", "SUCCESS", "FATAL", "COMPLETE"]
|
|
}
|
|
},
|
|
{
|
|
"in": "query",
|
|
"name": "search",
|
|
"description": "Case-insensitive plain-text search",
|
|
"schema": {
|
|
"type": "string",
|
|
"maxLength": 200
|
|
}
|
|
}
|
|
],
|
|
"responses": {
|
|
"200": {
|
|
"description": "200 response",
|
|
"content": {
|
|
"application/json": {
|
|
"examples": {
|
|
"default": {
|
|
"value": {
|
|
"lines": ["2026-01-01T00:00:00.000Z INFO [Global ] Backend PID 1 listening on port 3000 ..."],
|
|
"size": 4096,
|
|
"truncated": false,
|
|
"exists": true
|
|
}
|
|
}
|
|
},
|
|
"schema": {
|
|
"$ref": "../../../components/log-tail-object.json"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|