chore(logs): add explicit http logs
Default is now RUST_LOG=info,http=warn. Effect of each level on the access log: ┌────────────────────┬────────────────────────┐ │ Level on http │ Status classes emitted │ ├────────────────────┼────────────────────────┤ │ info │ 2xx/3xx + 4xx + 5xx │ ├────────────────────┼────────────────────────┤ │ warn (default) │ 4xx + 5xx │ ├────────────────────┼────────────────────────┤ │ error │ 5xx only │ ├────────────────────┼────────────────────────┤ │ off │ nothing │ └────────────────────┴────────────────────────┘ Target mapping: ┌────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┬─────────────────┐ │ Routes │ Target │ ├────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┼─────────────────┤ │ health_routes │ http::probe │ ├────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┼─────────────────┤ │ magic_link_router │ http::web │ ├────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┼─────────────────┤ │ All /api/auth/* sub-routers (login, register, refresh, public, protected, app_pw, device_public, device_protected) │ http::api::auth │ ├────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┼─────────────────┤ │ setup_router, public_api_routes, protected_api, wopi_api_protected │ http::api │ ├────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┼─────────────────┤ │ well_known_router, caldav_protected, carddav_protected, webdav_protected │ http::dav │ ├────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┼─────────────────┤ │ nc_router │ http::nextcloud │ ├────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┼─────────────────┤ │ wopi_protocol │ http::wopi │ ├────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┼─────────────────┤ │ web_routes (+ ServeDir fallback) │ http::web │ └────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┴─────────────────┘ # Default value: - **http=warn** if target http not specified - **http::web=error** if target http::web not specified Common operator overrides: # Server-error-only access logs (the new default) unset RUST_LOG # See login failures and other client errors on auth RUST_LOG=info,http=warn,http::api::auth=info # which is similar to RUST_LOG=info,http::api::auth=info # Full access log everywhere (heavy) RUST_LOG=info,http=info # Silence everything except errors RUST_LOG=warn
This commit is contained in:
@@ -15,7 +15,7 @@ use axum::{
|
||||
extract::{Path, Query, State},
|
||||
http::{HeaderMap, Request, StatusCode},
|
||||
response::{Html, IntoResponse, Response},
|
||||
routing::{get, post},
|
||||
routing::{any, get, post},
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::sync::Arc;
|
||||
@@ -568,6 +568,12 @@ pub fn wopi_routes(
|
||||
.route("/edit/{file_id}", get(host_page))
|
||||
// Supported extensions (public, no auth)
|
||||
.route("/supported-extensions", get(get_supported_extensions))
|
||||
// Collector for any unknown `/wopi/*` path — keeps the
|
||||
// access-log target as `http::wopi` instead of letting
|
||||
// M365/Collabora probes leak into `http::web` via the
|
||||
// ServeDir fallback. Same rationale as the NC `/ocs/*`
|
||||
// catch-all in interfaces/nextcloud/routes.rs.
|
||||
.route("/{*rest}", any(wopi_not_found))
|
||||
.with_state(wopi_state.clone());
|
||||
|
||||
let api_router = Router::new()
|
||||
@@ -576,3 +582,14 @@ pub fn wopi_routes(
|
||||
|
||||
(protocol_router, api_router)
|
||||
}
|
||||
|
||||
/// Catch-all 404 for unknown paths nested under `/wopi`. Exists
|
||||
/// purely to anchor the access-log target to `http::wopi` instead
|
||||
/// of letting the request fall through Axum's matcher to
|
||||
/// ServeDir and being mis-attributed to `http::web`.
|
||||
async fn wopi_not_found() -> Response {
|
||||
Response::builder()
|
||||
.status(StatusCode::NOT_FOUND)
|
||||
.body(Body::empty())
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user