Browse Source

Bug 20582: Fix PSGI file when behind a reverse proxy

ReverseProxy middleware can modify SERVER_PORT which is used to
determines which app (opac or intranet) to run, so the choice should be
made before ReverseProxy middleware

Signed-off-by: Jerome Charaoui <jcharaoui@cmaisonneuve.qc.ca>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
tags/v20.11.00
Julian Maurice 9 months ago
parent
commit
efc9a7d320
1 changed files with 14 additions and 2 deletions
  1. +14
    -2
      app.psgi

+ 14
- 2
app.psgi View File

@@ -41,12 +41,24 @@ my $port2app = {
};

builder {
# This middleware decides which app to run (opac or intranet) depending on
# SERVER_PORT. It must be run before ReverseProxy middleware which can
# modify SERVER_PORT
enable sub {
my $app = shift;
sub {
my $env = shift;
$env->{'koha.app'} = $port2app->{$env->{SERVER_PORT}} || $intranet;
return $app->($env);
}
};

enable 'ReverseProxy';
enable '+Koha::Middleware::SetEnv';
enable '+Koha::Middleware::RealIP';

sub {
my $env = shift;
my $app = $port2app->{$env->{SERVER_PORT}} || $intranet;
$app->($env);
$env->{'koha.app'}->($env);
};
}

Loading…
Cancel
Save