logger: Use forwarded instead of peer IP address (#3223)

This commit is contained in:
Óliver García Albertos 2023-06-22 08:34:51 +01:00 committed by GitHub
parent ef3544bac4
commit 985359918f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -165,7 +165,10 @@ pub async fn start_lemmy_server() -> Result<(), LemmyError> {
}; };
App::new() 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(cors_config)
.wrap(TracingLogger::<QuieterRootSpanBuilder>::new()) .wrap(TracingLogger::<QuieterRootSpanBuilder>::new())
.app_data(Data::new(context)) .app_data(Data::new(context))