[Koha] Working with nginx and installing on URL prefixes

Thomas Klausner domm at plix.at
Sat Oct 7 01:37:53 NZDT 2023


Hi!

On Fri, Oct 06, 2023 at 01:04:20PM +0200, Daniel Bünzli wrote:
 
> a) Is there an easy way to convince koha to root its URLs w.r.t. to 
> the prefix we’d like them to be on ? Maybe an environment variable or 
> a launch parameter or an http header to set in the nginx configuration 
> ? (I’m a bit unfamiliar with the whole plack/starman eco-system) 

AFAIK there isn't, and I had the same problem some time ago. The problem 
is mainly that a LOT of templates have hardcoded URLs starting with "/" 
in them (instead of using a resolver like uri_for, which could then 
consider some HTTP Headers to fiddle with the paths)

We ended up with some rather ugly rewrites (of the content, not the 
URLs!!!) using mod_substitute and mod_filter, plus a bunch of 
mod_rewrites (which are comparably easy)

  <Location "/some-other-path/">
    	AddOutputFilterByType SUBSTITUTE text/html text/plain application/json application/javascript
	Substitute "s|/cgi-bin/|/some-other-path/cgi-bin/|i"
	Substitute "s|/intranet-tmpl/|/some-other-path/intranet-tmpl/|i"
	Substitute "s|/api/v1/|/some-other-path/api/v1/|i"
  </Location>

This will take the output generated upstream (i.e. plack) and do actual 
regex replaces on the HTML. So ... ugh...

> b) Is there any strong problem I’m not seeing in trying to setup koha 
> the way I outlined above and use nginx rather than apache to serve the 
> app ?  

There might be some long-running scripts left that can only be run as 
CGI (because they fork). You can find those in apache-shared-intranet-plack.conf
after "# FIXME: These scripts should be fixed so they..." (at least in 
22.11). But maybe they all have been ported to RabbitMQ, in which case I 
think there should be no problems using nginx as a frontend (or maybe 
they can also be made to work with nginx?)

But maybe I also remeber this wrong, but I think we decided to keep 
Apache (even though I'd rather use nginx) because of these issues...

Hope that helps,

Greetings,
domm


-- 
Thomas Klausner               domm                  https://domm.plix.at
Just another ( Perl | Postgres | Bicycle | Food | Photo | Vinyl ) Hacker

A not-so-short list of things I learned at PerlKohaCon #Perl #Koha
[ 2023-08-19 10:00 > https://domm.plix.at/perl/2023_08_things_i_learned_at_perlkohacon.html ]

Long and good read: http://bit-player.org/2023/ai-and-the-end-of-programming
[ 2023-09-14 12:01 > https://domm.plix.at/microblog.html ]


More information about the Koha mailing list