From a852d66f018f3db06129b05e606b1606e9f00471 Mon Sep 17 00:00:00 2001 From: Chongyun Lee Date: Tue, 28 Dec 2021 22:26:46 +0800 Subject: [PATCH] Fix(logger): Ignore docker health check requests This patch disables logging of HTTP requests containing health-check UA from the local IP address. These logs can take up a lot of disk space but are of little use. Signed-off-by: Chongyun Lee --- app.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app.js b/app.js index b4451f951..d3c170f74 100644 --- a/app.js +++ b/app.js @@ -63,8 +63,14 @@ if (!config.useSSL && config.protocolUseSSL) { app.set('trust proxy', 1) } +// check if the request is from container healthcheck +function isContainerHealthCheck (req, _) { + return req.headers['user-agent'] === 'hedgedoc-container-healthcheck/1.0' && req.ip === '127.0.0.1' +} + // logger app.use(morgan('combined', { + skip: isContainerHealthCheck, stream: logger.stream }))