From 985359918f43234892f83d4b1de3116252cc9199 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=93liver=20Garc=C3=ADa=20Albertos?= <3skuero@gmail.com> Date: Thu, 22 Jun 2023 08:34:51 +0100 Subject: [PATCH] logger: Use forwarded instead of peer IP address (#3223) --- src/lib.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 1bc00f70c..f6ca79540 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -165,7 +165,10 @@ pub async fn start_lemmy_server() -> Result<(), LemmyError> { }; App::new() - .wrap(middleware::Logger::default()) + .wrap(middleware::Logger::new( + // This is the default log format save for the usage of %{r}a over %a to guarantee to record the client's (forwarded) IP and not the last peer address, since the latter is frequently just a reverse proxy + "%{r}a '%r' %s %b '%{Referer}i' '%{User-Agent}i' %T", + )) .wrap(cors_config) .wrap(TracingLogger::::new()) .app_data(Data::new(context))