Re: [Koha] Step by step guide to enable REST API koha 20.11
Those look correct. Have you seen koha-testing-docker? Kind regards El vie, 26 mar 2021 a las 8:44, Javier Legido at Kedu (< javier.legido@kedu.coop>) escribió:
Good morning.
Many thanks for your quick reply Tomas.
I will do the test with stable debian version just right now, but maybe you (or someone else) can confirm or discard if the provided steps are accurate in order to get the REST API up and running.
Thanks.
--
Javier Legido Martínez javier.legido@kedu.coop +34 600 840 948
Kedu SCCL https://kedu.coop info@kedu.coop
On Fri, 26 Mar 2021 at 12:36, Tomas Cohen Arazi <tomascohen@gmail.com> wrote:
Hi, we don't support Debian testing (things change often regarding dependencies and available packages).
Please use the debian:buster image instead.
Kind regards
El vie., 26 mar. 2021 1:50, Javi Legido <javi@legido.com> escribió:
Hi there.
I would like to enable REST API, but so far i got 404 while trying to access:
http://mykoha-intra.mydnsname.org/api/v1/.html
http://mykoha.myDNSname.org/api/v1/.html
I enabled below options:
OPACBaseURL => http://mykoha.myDNSname.org OpacPublic RESTBasicAuth RESTOAuth2ClientCredentials RESTPublicAnonymousRequests RESTPublicAPI
I see below errors in '/var/log/koha/mykoha/plack.log':
172.17.0.1 - - [26/Mar/2021:04:42:52 +0000] "GET /api/v1/ app.pl/api/v1/.html HTTP/1.1" 404 - "-" "Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0"
Many thanks in advice.
Now verbose things, configuration files and step by step ways to reproduce the issue:
1. Configuration files
/etc/apache2/sites-enabled/mykoha.conf
# Koha instance mykoha Apache config.
# OPAC <VirtualHost *:80> <IfVersion >= 2.4> Define instance "mykoha" </IfVersion> Include /etc/koha/apache-shared.conf # Include /etc/koha/apache-shared-disable.conf Include /etc/koha/apache-shared-opac-plack.conf Include /etc/koha/apache-shared-opac.conf
ServerName mykoha.myDNSname.org SetEnv KOHA_CONF "/etc/koha/sites/mykoha/koha-conf.xml" AssignUserID mykoha-koha mykoha-koha
ErrorLog /var/log/koha/mykoha/opac-error.log # TransferLog /var/log/koha/mykoha/opac-access.log </VirtualHost>
# Intranet <VirtualHost *:80> <IfVersion >= 2.4> Define instance "mykoha" </IfVersion> Include /etc/koha/apache-shared.conf # Include /etc/koha/apache-shared-disable.conf Include /etc/koha/apache-shared-intranet-plack.conf Include /etc/koha/apache-shared-intranet.conf
ServerName mykoha-intra.myDNSname.org SetEnv KOHA_CONF "/etc/koha/sites/mykoha/koha-conf.xml" AssignUserID mykoha-koha mykoha-koha
ErrorLog /var/log/koha/mykoha/intranet-error.log # TransferLog /var/log/koha/mykoha/intranet-access.log </VirtualHost>
/etc/koha/apache-shared-opac-plack.conf
# Apache configuration settings that are shared for every Koha instance. # This file contains settings for the Plack configuration of the OPAC. # # This file should be included from an instance's # /etc/apache2/site-available file, from within the VirtualHost section # for the OPAC.
# Plack is only available out-of-the-box for Apache 2.4.7+ setups <IfVersion >= 2.4.8> <IfModule mod_proxy_http.c>
ProxyPreserveHost On
RequestHeader set X-FORWARDED-PROTO "https" env=HTTPS
# Point the OPAC site to Plack ProxyPass /index.html "unix:/var/run/koha/${instance}/plack.sock| http://localhost/opac/opac-main.pl" ProxyPassReverse /index.html "unix:/var/run/koha/${instance}/plack.sock| http://localhost/opac/opac-main.pl" ProxyPass /cgi-bin/koha "unix:/var/run/koha/${instance}/plack.sock| http://localhost/opac" ProxyPassReverse /cgi-bin/koha "unix:/var/run/koha/${instance}/plack.sock|http://localhost/opac"
# Point the /api endpoint to Plack RewriteCond %{REQUEST_URI} !^/api/v[0-1]+/app.pl RewriteRule ^/api/(v[0-9]+)/(.*)$ /api/$1/app.pl/api/$1/$2 [L,PT]
ProxyPass /api "unix:/var/run/koha/${instance}/plack.sock| http://localhost/api" ProxyPassReverse /api "unix:/var/run/koha/${instance}/plack.sock| http://localhost/api"
</IfModule> </IfVersion>
/etc/koha/apache-shared-intranet-plack.conf
# Apache configuration settings that are shared for every Koha instance. # This file contains settings for the Plack configuration of the intranet. # # This file should be included from an instance's # /etc/apache2/site-available file, from within the VirtualHost section # for the intranet.
# Plack is only available out-of-the-box for Apache 2.4.8+ setups <IfVersion >= 2.4.8> <IfModule mod_proxy_http.c>
# FIXME: These scripts should be fixed so they # don't break under plack/starman ProxyPass "/cgi-bin/koha/offline_circ/process_koc.pl" "!" ProxyPass "/cgi-bin/koha/tools/background-job-progress.pl" "!" ProxyPass "/cgi-bin/koha/tools/batchMod.pl" "!" ProxyPass "/cgi-bin/koha/tools/export.pl" "!" ProxyPass "/cgi-bin/koha/tools/manage-marc-import.pl" "!" ProxyPass "/cgi-bin/koha/tools/stage-marc-import.pl" "!" ProxyPass "/cgi-bin/koha/tools/upload-cover-image.pl" "!" ProxyPass "/cgi-bin/koha/svc/cataloguing/metasearch" "!"
ProxyPreserveHost On
RequestHeader set X-FORWARDED-PROTO "https" env=HTTPS
# Point the intranet site to Plack ProxyPass /index.html "unix:/var/run/koha/${instance}/plack.sock| http://localhost/intranet/mainpage.pl" ProxyPassReverse /index.html "unix:/var/run/koha/${instance}/plack.sock| http://localhost/intranet/mainpage.pl" ProxyPass /cgi-bin/koha "unix:/var/run/koha/${instance}/plack.sock| http://localhost/intranet" ProxyPassReverse /cgi-bin/koha "unix:/var/run/koha/${instance}/plack.sock|http://localhost/intranet"
# Point the /api endpoint to Plack RewriteCond %{REQUEST_URI} !^/api/v[0-1]+/app.pl RewriteRule ^/api/(v[0-9]+)/(.*)$ /api/$1/app.pl/api/$1/$2 [L,PT]
ProxyPass /api "unix:/var/run/koha/${instance}/plack.sock| http://localhost/api" ProxyPassReverse /api "unix:/var/run/koha/${instance}/plack.sock| http://localhost/api"
</IfModule> </IfVersion>
2. Step by step way to reproduce the issue
docker stop test && docker rm test docker run \ --name test \ --cap-add=SYS_NICE \ --cap-add=DAC_READ_SEARCH \ -p 8080:8080 \ -p 80:80 \ -d debian:testing \ bin/sh -c "while true; do echo hello world; sleep 1; done" docker exec -ti test bash
apt-get update && apt-get install -y \ wget \ gnupg
wget -q -O- https://debian.koha-community.org/koha/gpg.asc | apt-key add -
echo 'deb http://debian.koha-community.org/koha stable main' | tee /etc/apt/sources.list.d/koha.list
apt-get update && apt-get install -y \ koha-common \ mariadb-server
service mariadb start
a2enmod rewrite \ cgi \ headers \ proxy_http \ && a2dissite 000-default
service apache2 restart
koha-create --create-db mykoha
koha-plack --enable mykoha
koha-plack --start mykoha
service apache2 restart _______________________________________________
Koha mailing list http://koha-community.org Koha@lists.katipo.co.nz Unsubscribe: https://lists.katipo.co.nz/mailman/listinfo/koha
-- Tomás Cohen Arazi Theke Solutions (http://theke.io) ✆ +54 9351 3513384 GPG: B2F3C15F
Good afternoon. Many thanks, it worked like a charm! I'll post the steps at the end of this e-mail. Regarding koha-testing-docker I've just tried now and it gave me an error, maybe I'll fill a bug, but thanks in advance. Steps with buster. buster koha 20.11 docker stop test && docker rm test docker run \ --name test \ --cap-add=SYS_NICE \ --cap-add=DAC_READ_SEARCH \ -p 8080:8080 \ -p 80:80 \ -d debian:buster \ bin/sh -c "while true; do echo hello world; sleep 1; done" docker exec -ti test bash apt-get update && apt-get install -y \ wget \ gnupg wget -q -O- https://debian.koha-community.org/koha/gpg.asc | apt-key add - echo 'deb http://debian.koha-community.org/koha stable main' | tee /etc/apt/sources.list.d/koha.list apt-get update && apt-get install -y \ koha-common \ mariadb-server service mysql start a2enmod rewrite \ cgi \ headers \ proxy_http \ && a2dissite 000-default koha-create --create-db mykoha koha-plack --enable mykoha koha-plack --start mykoha service apache2 restart GUI install docker exec -ti test koha-passwd mykoha http://mykoha-intra.mydnsname.org koha_mykoha ***** http://mykoha-intra.mydnsname.org/api/v1/.html Voila! On Fri, 26 Mar 2021 at 12:50, Tomas Cohen Arazi <tomascohen@gmail.com> wrote:
Those look correct.
Have you seen koha-testing-docker?
Kind regards
El vie, 26 mar 2021 a las 8:44, Javier Legido at Kedu (< javier.legido@kedu.coop>) escribió:
Good morning.
Many thanks for your quick reply Tomas.
I will do the test with stable debian version just right now, but maybe you (or someone else) can confirm or discard if the provided steps are accurate in order to get the REST API up and running.
Thanks.
--
Javier Legido Martínez javier.legido@kedu.coop +34 600 840 948
Kedu SCCL https://kedu.coop info@kedu.coop
On Fri, 26 Mar 2021 at 12:36, Tomas Cohen Arazi <tomascohen@gmail.com> wrote:
Hi, we don't support Debian testing (things change often regarding dependencies and available packages).
Please use the debian:buster image instead.
Kind regards
El vie., 26 mar. 2021 1:50, Javi Legido <javi@legido.com> escribió:
Hi there.
I would like to enable REST API, but so far i got 404 while trying to access:
http://mykoha-intra.mydnsname.org/api/v1/.html
http://mykoha.myDNSname.org/api/v1/.html
I enabled below options:
OPACBaseURL => http://mykoha.myDNSname.org OpacPublic RESTBasicAuth RESTOAuth2ClientCredentials RESTPublicAnonymousRequests RESTPublicAPI
I see below errors in '/var/log/koha/mykoha/plack.log':
172.17.0.1 - - [26/Mar/2021:04:42:52 +0000] "GET /api/v1/ app.pl/api/v1/.html HTTP/1.1" 404 - "-" "Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0"
Many thanks in advice.
Now verbose things, configuration files and step by step ways to reproduce the issue:
1. Configuration files
/etc/apache2/sites-enabled/mykoha.conf
# Koha instance mykoha Apache config.
# OPAC <VirtualHost *:80> <IfVersion >= 2.4> Define instance "mykoha" </IfVersion> Include /etc/koha/apache-shared.conf # Include /etc/koha/apache-shared-disable.conf Include /etc/koha/apache-shared-opac-plack.conf Include /etc/koha/apache-shared-opac.conf
ServerName mykoha.myDNSname.org SetEnv KOHA_CONF "/etc/koha/sites/mykoha/koha-conf.xml" AssignUserID mykoha-koha mykoha-koha
ErrorLog /var/log/koha/mykoha/opac-error.log # TransferLog /var/log/koha/mykoha/opac-access.log </VirtualHost>
# Intranet <VirtualHost *:80> <IfVersion >= 2.4> Define instance "mykoha" </IfVersion> Include /etc/koha/apache-shared.conf # Include /etc/koha/apache-shared-disable.conf Include /etc/koha/apache-shared-intranet-plack.conf Include /etc/koha/apache-shared-intranet.conf
ServerName mykoha-intra.myDNSname.org SetEnv KOHA_CONF "/etc/koha/sites/mykoha/koha-conf.xml" AssignUserID mykoha-koha mykoha-koha
ErrorLog /var/log/koha/mykoha/intranet-error.log # TransferLog /var/log/koha/mykoha/intranet-access.log </VirtualHost>
/etc/koha/apache-shared-opac-plack.conf
# Apache configuration settings that are shared for every Koha instance. # This file contains settings for the Plack configuration of the OPAC. # # This file should be included from an instance's # /etc/apache2/site-available file, from within the VirtualHost section # for the OPAC.
# Plack is only available out-of-the-box for Apache 2.4.7+ setups <IfVersion >= 2.4.8> <IfModule mod_proxy_http.c>
ProxyPreserveHost On
RequestHeader set X-FORWARDED-PROTO "https" env=HTTPS
# Point the OPAC site to Plack ProxyPass /index.html "unix:/var/run/koha/${instance}/plack.sock| http://localhost/opac/opac-main.pl" ProxyPassReverse /index.html "unix:/var/run/koha/${instance}/plack.sock| http://localhost/opac/opac-main.pl" ProxyPass /cgi-bin/koha "unix:/var/run/koha/${instance}/plack.sock| http://localhost/opac" ProxyPassReverse /cgi-bin/koha "unix:/var/run/koha/${instance}/plack.sock|http://localhost/opac"
# Point the /api endpoint to Plack RewriteCond %{REQUEST_URI} !^/api/v[0-1]+/app.pl RewriteRule ^/api/(v[0-9]+)/(.*)$ /api/$1/app.pl/api/$1/$2 [L,PT]
ProxyPass /api "unix:/var/run/koha/${instance}/plack.sock| http://localhost/api" ProxyPassReverse /api "unix:/var/run/koha/${instance}/plack.sock| http://localhost/api"
</IfModule> </IfVersion>
/etc/koha/apache-shared-intranet-plack.conf
# Apache configuration settings that are shared for every Koha instance. # This file contains settings for the Plack configuration of the intranet. # # This file should be included from an instance's # /etc/apache2/site-available file, from within the VirtualHost section # for the intranet.
# Plack is only available out-of-the-box for Apache 2.4.8+ setups <IfVersion >= 2.4.8> <IfModule mod_proxy_http.c>
# FIXME: These scripts should be fixed so they # don't break under plack/starman ProxyPass "/cgi-bin/koha/offline_circ/process_koc.pl" "!" ProxyPass "/cgi-bin/koha/tools/background-job-progress.pl" "!" ProxyPass "/cgi-bin/koha/tools/batchMod.pl" "!" ProxyPass "/cgi-bin/koha/tools/export.pl" "!" ProxyPass "/cgi-bin/koha/tools/manage-marc-import.pl" "!" ProxyPass "/cgi-bin/koha/tools/stage-marc-import.pl" "!" ProxyPass "/cgi-bin/koha/tools/upload-cover-image.pl" "!" ProxyPass "/cgi-bin/koha/svc/cataloguing/metasearch" "!"
ProxyPreserveHost On
RequestHeader set X-FORWARDED-PROTO "https" env=HTTPS
# Point the intranet site to Plack ProxyPass /index.html "unix:/var/run/koha/${instance}/plack.sock| http://localhost/intranet/mainpage.pl" ProxyPassReverse /index.html "unix:/var/run/koha/${instance}/plack.sock| http://localhost/intranet/mainpage.pl" ProxyPass /cgi-bin/koha "unix:/var/run/koha/${instance}/plack.sock| http://localhost/intranet" ProxyPassReverse /cgi-bin/koha "unix:/var/run/koha/${instance}/plack.sock|http://localhost/intranet"
# Point the /api endpoint to Plack RewriteCond %{REQUEST_URI} !^/api/v[0-1]+/app.pl RewriteRule ^/api/(v[0-9]+)/(.*)$ /api/$1/app.pl/api/$1/$2 [L,PT]
ProxyPass /api "unix:/var/run/koha/${instance}/plack.sock| http://localhost/api" ProxyPassReverse /api "unix:/var/run/koha/${instance}/plack.sock| http://localhost/api"
</IfModule> </IfVersion>
2. Step by step way to reproduce the issue
docker stop test && docker rm test docker run \ --name test \ --cap-add=SYS_NICE \ --cap-add=DAC_READ_SEARCH \ -p 8080:8080 \ -p 80:80 \ -d debian:testing \ bin/sh -c "while true; do echo hello world; sleep 1; done" docker exec -ti test bash
apt-get update && apt-get install -y \ wget \ gnupg
wget -q -O- https://debian.koha-community.org/koha/gpg.asc | apt-key add -
echo 'deb http://debian.koha-community.org/koha stable main' | tee /etc/apt/sources.list.d/koha.list
apt-get update && apt-get install -y \ koha-common \ mariadb-server
service mariadb start
a2enmod rewrite \ cgi \ headers \ proxy_http \ && a2dissite 000-default
service apache2 restart
koha-create --create-db mykoha
koha-plack --enable mykoha
koha-plack --start mykoha
service apache2 restart _______________________________________________
Koha mailing list http://koha-community.org Koha@lists.katipo.co.nz Unsubscribe: https://lists.katipo.co.nz/mailman/listinfo/koha
-- Tomás Cohen Arazi Theke Solutions (http://theke.io) ✆ +54 9351 3513384 GPG: B2F3C15F
participants (2)
-
Javi Legido -
Tomas Cohen Arazi