[Bug 33967] New: REMOTE_ADDR incorrect in plack.log when run behind a proxy
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=33967 Bug ID: 33967 Summary: REMOTE_ADDR incorrect in plack.log when run behind a proxy Change sponsored?: --- Product: Koha Version: master Hardware: All OS: All Status: NEW Severity: enhancement Priority: P5 - low Component: Architecture, internals, and plumbing Assignee: koha-bugs@lists.koha-community.org Reporter: dcook@prosentient.com.au QA Contact: testopia@bugs.koha-community.org As I note in https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=23068#c54 the Koha::Middleware::SetEnv breaks the flow of $env through the Plack middleware wrapper chain. This means that post-processing middleware that happen after Koha::Middleware::SetEnv (e.g. Plack::Middleware::AccessLog) will use the wrong $env variable (ie the $env variable that was being used before Koha::Middleware::SetEnv was run in the pre-process middleware phase). By retaining the original $env hashref in Koha::Middleware::SetEnv, we should be able to preserve the referential integrity. Going to give a patch a go now... -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=33967 David Cook <dcook@prosentient.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- Depends on| |23068 Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=23068 [Bug 23068] Add ability for Koha to handle X-Forwarded-For headers so REMOTE_ADDR features work behind a proxy -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=33967 David Cook <dcook@prosentient.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|koha-bugs@lists.koha-commun |dcook@prosentient.com.au |ity.org | -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=33967 David Cook <dcook@prosentient.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- Severity|enhancement |normal -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=33967 David Cook <dcook@prosentient.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |Needs Signoff -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=33967 --- Comment #1 from David Cook <dcook@prosentient.com.au> --- Created attachment 152227 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=152227&action=edit Bug 33967: Fix SetEnv middleware to preserve $env integrity This patch fixes the Koha::Middleware::SetEnv, so that it preserves the referential integrity of the $env hash reference as it passes through the pre-process and post-process stages of middleware wrapped around the core Koha Plack application. Test plan: 0a. Apply the patch 0b. vi /etc/koha/sites/kohadev/koha-conf.xml 0c. Uncomment "koha_trusted_proxies" 0d. Add "172.0.0.0/8" to the end of the "koha_trusted_proxies" 0e. koha-plack --restart kohadev 1. vi /etc/apache2/sites-enabled/kohadev.conf 2. Add the following to the OPAC virtualhost: SetEnv OVERRIDE_SYSPREF_LibraryName "The Best, Truly the Best, Koha Library" RequestHeader add X-Koha-SetEnv "OVERRIDE_SYSPREF_LibraryName The Best\, Truly the Best\, Koha Library" RequestHeader add X-Forwarded-For "192.168.100.100" 3. service apache2 restart 4. tail -f /var/log/koha/kohadev/plack.log 5. Go to http://localhost:8080/ 6. Note that the plack.log lists 192.168.100.100 as the client IP address 7. Note that the title of the OPAC webpage is "The Best, Truly the Best, Koha Library Library catalog" -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=33967 David Nind <david@davidnind.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |Signed Off -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=33967 David Nind <david@davidnind.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #152227|0 |1 is obsolete| | --- Comment #2 from David Nind <david@davidnind.com> --- Created attachment 152228 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=152228&action=edit Bug 33967: Fix SetEnv middleware to preserve $env integrity This patch fixes the Koha::Middleware::SetEnv, so that it preserves the referential integrity of the $env hash reference as it passes through the pre-process and post-process stages of middleware wrapped around the core Koha Plack application. Test plan: 0a. Apply the patch 0b. vi /etc/koha/sites/kohadev/koha-conf.xml 0c. Uncomment "koha_trusted_proxies" 0d. Add "172.0.0.0/8" to the end of the "koha_trusted_proxies" 0e. koha-plack --restart kohadev 1. vi /etc/apache2/sites-enabled/kohadev.conf 2. Add the following to the OPAC virtualhost: SetEnv OVERRIDE_SYSPREF_LibraryName "The Best, Truly the Best, Koha Library" RequestHeader add X-Koha-SetEnv "OVERRIDE_SYSPREF_LibraryName The Best\, Truly the Best\, Koha Library" RequestHeader add X-Forwarded-For "192.168.100.100" 3. service apache2 restart 4. tail -f /var/log/koha/kohadev/plack.log 5. Go to http://localhost:8080/ 6. Note that the plack.log lists 192.168.100.100 as the client IP address 7. Note that the title of the OPAC webpage is "The Best, Truly the Best, Koha Library Library catalog" Signed-off-by: David Nind <david@davidnind.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=33967 --- Comment #3 from David Cook <dcook@prosentient.com.au> --- Created attachment 152229 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=152229&action=edit Bug 33967: Add unit test to ensure SetEnv doesn't compromise $env This patch includes a unit test which checks the memory address of the $env hashref in middlewares before and after Koha::Middleware::Env is applied. It succeeds when the same $env is maintained before and after this middleware. It fails if the $env has been overwritten with a new hashref (as evidenced by the new memory address for the hash). -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=33967 David Cook <dcook@prosentient.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #152229|0 |1 is obsolete| | --- Comment #4 from David Cook <dcook@prosentient.com.au> --- Created attachment 152230 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=152230&action=edit Bug 33967: Add unit test to ensure SetEnv doesn't compromise $env This patch includes a unit test which checks the memory address of the $env hashref in middlewares before and after Koha::Middleware::Env is applied. It succeeds when the same $env is maintained before and after this middleware. It fails if the $env has been overwritten with a new hashref (as evidenced by the new memory address for the hash). -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=33967 --- Comment #5 from David Cook <dcook@prosentient.com.au> --- If you want to verify the unit test works, you can either run it before applying the first patch, or you can compromise Koha/Middleware/SetEnv.pm by adding the following: $env = {}; right before the final return in the call sub. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=33967 Kyle M Hall <kyle@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |kyle@bywatersolutions.com QA Contact|testopia@bugs.koha-communit |kyle@bywatersolutions.com |y.org | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=33967 Kyle M Hall <kyle@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Signed Off |Passed QA -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=33967 Kyle M Hall <kyle@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #152228|0 |1 is obsolete| | Attachment #152230|0 |1 is obsolete| | --- Comment #6 from Kyle M Hall <kyle@bywatersolutions.com> --- Created attachment 152241 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=152241&action=edit Bug 33967: Fix SetEnv middleware to preserve $env integrity This patch fixes the Koha::Middleware::SetEnv, so that it preserves the referential integrity of the $env hash reference as it passes through the pre-process and post-process stages of middleware wrapped around the core Koha Plack application. Test plan: 0a. Apply the patch 0b. vi /etc/koha/sites/kohadev/koha-conf.xml 0c. Uncomment "koha_trusted_proxies" 0d. Add "172.0.0.0/8" to the end of the "koha_trusted_proxies" 0e. koha-plack --restart kohadev 1. vi /etc/apache2/sites-enabled/kohadev.conf 2. Add the following to the OPAC virtualhost: SetEnv OVERRIDE_SYSPREF_LibraryName "The Best, Truly the Best, Koha Library" RequestHeader add X-Koha-SetEnv "OVERRIDE_SYSPREF_LibraryName The Best\, Truly the Best\, Koha Library" RequestHeader add X-Forwarded-For "192.168.100.100" 3. service apache2 restart 4. tail -f /var/log/koha/kohadev/plack.log 5. Go to http://localhost:8080/ 6. Note that the plack.log lists 192.168.100.100 as the client IP address 7. Note that the title of the OPAC webpage is "The Best, Truly the Best, Koha Library Library catalog" Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=33967 --- Comment #7 from Kyle M Hall <kyle@bywatersolutions.com> --- Created attachment 152242 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=152242&action=edit Bug 33967: Add unit test to ensure SetEnv doesn't compromise $env This patch includes a unit test which checks the memory address of the $env hashref in middlewares before and after Koha::Middleware::Env is applied. It succeeds when the same $env is maintained before and after this middleware. It fails if the $env has been overwritten with a new hashref (as evidenced by the new memory address for the hash). Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=33967 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Version(s)| |23.11.00 released in| | Status|Passed QA |Pushed to master -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=33967 --- Comment #8 from Tomás Cohen Arazi <tomascohen@gmail.com> --- Pushed to master for 23.11. Nice work everyone, thanks! -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=33967 Martin Renvoize <martin.renvoize@ptfs-europe.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Version(s)|23.11.00 |23.11.00,23.05.02 released in| | Status|Pushed to master |Pushed to stable -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=33967 --- Comment #9 from Martin Renvoize <martin.renvoize@ptfs-europe.com> --- Thanks for all the hard work! Pushed to 23.05.x for the next release -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=33967 Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Version(s)|23.11.00,23.05.02 |23.11.00,23.05.02,22.11.08 released in| | Status|Pushed to stable |Pushed to oldstable -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=33967 --- Comment #10 from Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com> --- Nice work everyone! Pushed to oldstable for 22.11.x -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org