[Koha-bugs] [Bug 23068] Add ability for Koha to handle X-Forwarded-For headers so REMOTE_ADDR features work behind a proxy

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Fri Jun 9 05:36:43 CEST 2023


https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=23068

--- Comment #54 from David Cook <dcook at prosentient.com.au> ---
The problem is Koha::Middleware::SetEnv. It's a fundamentally flawed
middleware.

The wrapping of middleware works by passing around a hash reference (ie $env),
and Koha::Middleware::SetEnv breaks the referential train.

It passes a new hashref to Koha::Middleware::RealIP which then passes that new
reference to the Koha app. 

But when the post-processing aspect of the Plack middleware runs, after leaving
the Koha::Middleware::SetEnv wrapper, it goes back to Plack::Middleware::Static
which has the *original* reference, which undoes the changes of
Koha::Middleware::SetEnv wrapper and Koha::Middleware::RealIP.

We don't notice this because a lot of our middleware only "pre-process". But
Plack::Middleware::AccessLog" is a "post-process" middleware.

This should actually be a fairly easy fix, and it'll fix the IP address in
plack.log when running behind a reverse proxy.

-- 
You are receiving this mail because:
You are watching all bug changes.


More information about the Koha-bugs mailing list