The current plack-on-packages schema points the apache vhost (for example for the intranet) like this: /cgi-bin/koha/ => /intranet/ So the code that uses ENV{SCRIPT_NAME} "sees" it is being called for example like /intranet/mainpage.pl. This gets problematic in some scenarios, because it is used to then redirect the browser, or to create links to things. Steps to reproduce: - Check out an old DBRev in the koha repo (1 step older is ok) - Pick the ansible branch from the kohadevbox [1] - Launch it, on jessie: $ vagrant up jessie - Log into it $ vagrant ssh jessie - Enable Plack for the automatically created instance $ sudo koha-plack --enable kohadev $ sudo koha-plack --start kohadev $ sudo service apache2 restart - Get the DB password to be able to login $ koha-pass - Point your browser to the staff interface: http://localhost:8081 - Login with koha_kohadev and the retrieved password => FAIL: You cannot login - Disable Plack for the instance $ sudo koha-plack --disable kohadev $ sudo koha-plack --stop kohadev $ sudo service apache2 restart - Point your browser to the staff interface: http://localhost:8081 - Login with koha_kohadev and the retrieved password => SUCCESS: You can login - Proceed to install with the default data (you can try enabling plack and you will notice it works) - Once you are in, enable plack $ sudo koha-plack --enable kohadev $ sudo koha-plack --start kohadev $ sudo service apache2 restart - Checkout the latest master (so it triggers an update) - Go somewhere inside (about?) - You are required to login (which is expected) => FAIL: the links back are pointing to /intranet/ so they are shortcircuited to the installer cyclically (see screenshot) [1] https://github.com/digibib/kohadevbox/tree/ansible
Created attachment 43383 [details] Wrong links generated
Created attachment 43387 [details] [review] Bug 15005: Replace CGI->url with the corresponding url CGI->url does not return the correct url on install using packages. Test plan: 1/ Try to reproduce the bug from the description of bug 15005. You should be able to login to the intranet and the OPAC 2/ Send a basket and a list from the intranet and the OPAC.
Created attachment 43388 [details] [review] Bug 15005: Remove CGI->url calls from pl scripts Same as previous patch for calls in pl scripts. Test plan: - delete an entry of your search history from intranet and opac - with IndependentBranches=OFF, go on the waiting holds and confirm that the link next to 'Holds awaiting pickup for your library on' is correct. - search for items, the pagination should work correctly
Created attachment 43389 [details] [review] Bug 15005: Fix pagination_bar calls Test plan: Create an order for an existing biblio, confirm that the pagination links work correctly.
Breaking news: Add this line to /etc/koha/sites/kohadev/plack.psgi enable "ReverseProxyPath"; And this one to /etc/koha/apache-shared-intranet-plack.conf RequestHeader set "X-Forwarded-Script-Name" /cgi-bin/koha fix the $ENV{SCRIPT_NAME}! ($cgi->url still does not work)
Created attachment 43443 [details] [review] Bug 15005: Use ReverseProxyPath on plack.psgi This patch makes plack.psgi use ReverseProxyPath so %ENV{SCRIPT_NAME} is correctly set when running Koha behind a reverse proxy that changes the URI path (which is done on the Plack integration into packages). The apache includes for plack are tweaked so the needed headers are set before passing the request to the Plack backend. Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Created attachment 43444 [details] [review] Bug 15005: Use ReverseProxyPath on plack.psgi This patch makes plack.psgi use ReverseProxyPath so %ENV{SCRIPT_NAME} is correctly set when running Koha behind a reverse proxy that changes the URI path (which is done on the Plack integration into packages). The apache includes for plack are tweaked so the needed headers are set before passing the request to the Plack backend. Edit: added missing dependency Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Created attachment 43447 [details] [review] Bug 15005: Replace CGI->url with the corresponding url CGI->url does not return the correct url on install using packages. Test plan: 1/ Try to reproduce the bug from the description of bug 15005. You should be able to login to the intranet and the OPAC 2/ Send a basket and a list from the intranet and the OPAC. Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Created attachment 43448 [details] [review] Bug 15005: Remove CGI->url calls from pl scripts Same as previous patch for calls in pl scripts. Test plan: - delete an entry of your search history from intranet and opac - with IndependentBranches=OFF, go on the waiting holds and confirm that the link next to 'Holds awaiting pickup for your library on' is correct. - search for items, the pagination should work correctly Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Created attachment 43449 [details] [review] Bug 15005: Fix pagination_bar calls Test plan: Create an order for an existing biblio, confirm that the pagination links work correctly. Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
The patches works as expected.
Created attachment 43451 [details] [review] Bug 15005: Replace $ENV{SCRIPT_NAME} with the hardcoded script paths Since I don't manage to make SCRIPT_NAME works directly with RequestHeader and/or ReverseProxyPath, the easier way it to fix all the different occurrences.
(In reply to Tomás Cohen Arazi from comment #7) > Created attachment 43444 [details] [review] [review] > Bug 15005: Use ReverseProxyPath on plack.psgi > > This patch makes plack.psgi use ReverseProxyPath so %ENV{SCRIPT_NAME} is > correctly set when running Koha behind a reverse proxy that changes > the URI path (which is done on the Plack integration into packages). > > The apache includes for plack are tweaked so the needed headers are set > before passing the request to the Plack backend. > > Edit: added missing dependency > > Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Tomas, Unfortunately, this does not work, the path generated is now /cgi-bin/koha/intranet/modules/script.pl (note the '/intranet'). The last patch I have proposed should fix the issue on a silly way (but working...).
Created attachment 43452 [details] [review] Bug 15005: Replace CGI->url with the corresponding url CGI->url does not return the correct url on install using packages. Test plan: 1/ Try to reproduce the bug from the description of bug 15005. You should be able to login to the intranet and the OPAC 2/ Send a basket and a list from the intranet and the OPAC. Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Created attachment 43453 [details] [review] Bug 15005: Remove CGI->url calls from pl scripts Same as previous patch for calls in pl scripts. Test plan: - delete an entry of your search history from intranet and opac - with IndependentBranches=OFF, go on the waiting holds and confirm that the link next to 'Holds awaiting pickup for your library on' is correct. - search for items, the pagination should work correctly Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Created attachment 43454 [details] [review] Bug 15005: Fix pagination_bar calls Test plan: Create an order for an existing biblio, confirm that the pagination links work correctly. Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Created attachment 43455 [details] [review] Bug 15005: Replace $ENV{SCRIPT_NAME} with the hardcoded script paths Since I don't manage to make SCRIPT_NAME works directly with RequestHeader and/or ReverseProxyPath, the easier way it to fix all the different occurrences. Test plan: On the import patrons page, confirm that the "Import" button does not redirect to a 'Not found' page. You should stay on the import patrons page. Note that if this change works, all others should work too. Have a look at the diff of this patch and confirm there is no typo.
*** Bug 15014 has been marked as a duplicate of this bug. ***
*** Bug 15015 has been marked as a duplicate of this bug. ***
*** Bug 15016 has been marked as a duplicate of this bug. ***
Created attachment 43484 [details] [review] Bug 15005: Replace $ENV{SCRIPT_NAME} with the hardcoded script paths Since I don't manage to make SCRIPT_NAME works directly with RequestHeader and/or ReverseProxyPath, the easier way it to fix all the different occurrences. Test plan: On the import patrons page, confirm that the "Import" button does not redirect to a 'Not found' page. You should stay on the import patrons page. Note that if this change works, all others should work too. Have a look at the diff of this patch and confirm there is no typo. Signed-off-by: Josef Moravec <josef.moravec@gmail.com> Tested in patron import and item batch modification
Created attachment 43534 [details] [review] [PASSED QA] Bug 15005: Replace CGI->url with the corresponding url CGI->url does not return the correct url on install using packages. Test plan: 1/ Try to reproduce the bug from the description of bug 15005. You should be able to login to the intranet and the OPAC 2/ Send a basket and a list from the intranet and the OPAC. Signed-off-by: Josef Moravec <josef.moravec@gmail.com> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Created attachment 43535 [details] [review] [PASSED QA] Bug 15005: Remove CGI->url calls from pl scripts Same as previous patch for calls in pl scripts. Test plan: - delete an entry of your search history from intranet and opac - with IndependentBranches=OFF, go on the waiting holds and confirm that the link next to 'Holds awaiting pickup for your library on' is correct. - search for items, the pagination should work correctly Signed-off-by: Josef Moravec <josef.moravec@gmail.com> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Created attachment 43536 [details] [review] [PASSED QA] Bug 15005: Fix pagination_bar calls Test plan: Create an order for an existing biblio, confirm that the pagination links work correctly. Signed-off-by: Josef Moravec <josef.moravec@gmail.com> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Created attachment 43537 [details] [review] [PASSED QA] Bug 15005: Replace $ENV{SCRIPT_NAME} with the hardcoded script paths Since I don't manage to make SCRIPT_NAME works directly with RequestHeader and/or ReverseProxyPath, the easier way it to fix all the different occurrences. Test plan: On the import patrons page, confirm that the "Import" button does not redirect to a 'Not found' page. You should stay on the import patrons page. Note that if this change works, all others should work too. Have a look at the diff of this patch and confirm there is no typo. Signed-off-by: Josef Moravec <josef.moravec@gmail.com> Tested in patron import and item batch modification Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Note: SCRIPT_NAME is referenced in a number of templates and a few perl scripts. In some cases it is passed to the template as a parameter. In others it is not, which makes the form action submit to the current url. As far as I'm aware this works fine and is non-detrimental, but I did want to make a note of it.
Patches pushed to master. Thanks Jonathan! We need to fill an enhancement bug for letting Koha stand in whatever endpoint we want instead of the legacy URI path.