Last active
April 20, 2024 22:11
-
-
Save jajm/963e7ade04cd7e4c62f7881991296b04 to your computer and use it in GitHub Desktop.
Koha / Starman / Nginx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /home/koha/app.psgi | |
use Modern::Perl; | |
use Plack::Builder; | |
use Plack::App::CGIBin; | |
use Plack::App::Directory; | |
use Plack::App::URLMap; | |
use Mojo::Server::PSGI; | |
# Pre-load libraries | |
use C4::Boolean; | |
use C4::Context; | |
use C4::Koha; | |
use C4::Languages; | |
use C4::Letters; | |
use C4::Members; | |
use C4::XSLT; | |
use Koha::Caches; | |
use Koha::Cache::Memory::Lite; | |
use Koha::Database; | |
use Koha::DateUtils; | |
use CGI qw(-utf8 ); # we will loose -utf8 under plack, otherwise | |
{ | |
no warnings 'redefine'; | |
my $old_new = \&CGI::new; | |
*CGI::new = sub { | |
my $q = $old_new->( @_ ); | |
$CGI::PARAM_UTF8 = 1; | |
Koha::Caches->flush_L1_caches(); | |
Koha::Cache::Memory::Lite->flush(); | |
return $q; | |
}; | |
} | |
my $root = Plack::App::CGIBin->new( | |
root => '/home/koha/src' | |
)->to_app; | |
my $rest = builder { | |
my $server = Mojo::Server::PSGI->new; | |
$server->load_app("/home/koha/src/api/v1/app.pl"); | |
$server->to_psgi_app; | |
}; | |
builder { | |
enable "ReverseProxy"; | |
mount '/' => $root; | |
mount '/api/v1/app.pl' => $rest; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /etc/nginx/fcgiwrap_location | |
location @fcgiwrap { | |
include fastcgi_params; | |
fastcgi_param KOHA_CONF /home/koha/etc/koha-conf.xml; | |
fastcgi_param PERL5LIB /home/koha/src; | |
fastcgi_split_path_info ^(?|(.+\.pl)(.*)|(.*)\/()|(.*)())$; | |
fastcgi_param SCRIPT_FILENAME /home/koha/src$fastcgi_script_name; | |
fastcgi_param PATH_INFO $fastcgi_path_info; | |
fastcgi_pass unix:/var/run/fcgiwrap.socket; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /etc/nginx/sites-available/koha | |
server { | |
server_name opac.koha-dev; | |
error_log /home/koha/var/log/koha-opac-error.log; | |
root /home/koha/src/koha-tmpl; | |
rewrite ^/$ /cgi-bin/koha/opac-main.pl; | |
rewrite ^/cgi-bin/koha/(.*)$ /opac/$1; | |
rewrite ^/api/(.*)$ /api/v1/app.pl/api/$1; | |
location / { | |
try_files $uri @starman; | |
} | |
include starman_location; | |
include plugin_location; | |
} | |
server { | |
server_name pro.koha-dev; | |
error_log /home/koha/var/log/koha-error.log; | |
root /home/koha/src/koha-tmpl; | |
rewrite ^/$ /cgi-bin/koha/mainpage.pl; | |
rewrite ^/cgi-bin/koha/(.*)$ /$1; | |
rewrite ^/api/(.*)$ /api/v1/app.pl/api/$1; | |
location / { | |
try_files $uri @starman; | |
} | |
include starman_location; | |
include plugin_location; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /etc/nginx/plugin_location | |
location /plugin { | |
alias /home/koha/var/lib/plugins; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /etc/nginx/starman_location | |
location @starman { | |
include proxy_params; | |
proxy_set_header X-Forwarded-Host $http_host; | |
keepalive_timeout 300s; | |
proxy_read_timeout 300s; | |
proxy_send_timeout 300s; | |
proxy_pass http://unix:/home/koha/var/run/starman.sock; | |
proxy_intercept_errors on; | |
error_page 502 = @fcgiwrap; | |
} | |
include fcgiwrap_location; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment