From be3e5186294e1a3c16b9078ecc3f4fe8e553e0f8 Mon Sep 17 00:00:00 2001 From: Olli-Antti Kivilahti Date: Mon, 3 Aug 2015 17:54:51 +0300 Subject: [PATCH] Bug 13799 - 1.1 RESTful API with reverse proxy configuration without api.host.domain OPTIONAL replacement to the Buugg 13799: 1. RESTful API with Mojolicious and Swagger2 httpd-configuration. Instead of having to go to your dns-provider, you can run the api from your current virtualhost. Use these configurations to reverse proxy www.host.domain/v1/ to the REST API. --------------------------- :INSTALLATION INSTRUCTIONS: --------------------------- You need Buugg 14448 - Adding the REST API as a Hypnotoad service, koha-api-daemon. to deploy the backend Mojolicous application as a FastCGI-daemon. Then add the modifications from etc/koha-httpd.conf to your /etc/apache2/sites-enabled/koha.conf and adjust paths to fit. ..$ a2enmod proxy ..$ a2enmod proxy_http ..$ service apache2 restart Much recommended is Buugg 14458: 5. Add SwaggerUI documentation for RESTful API to browse your API capabilities. Then just go to /v1/doc to see the API autodocumentation. --- etc/koha-httpd.conf | 43 ++++++++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/etc/koha-httpd.conf b/etc/koha-httpd.conf index 000e94a..98ab216 100644 --- a/etc/koha-httpd.conf +++ b/etc/koha-httpd.conf @@ -27,6 +27,18 @@ # OVERRIDE_SYSPREF_NAMES for your staff intranet vhost # SetEnv OVERRIDE_SYSPREF_PrefName Value + ##REVERSE PROXY REQUESTS TO THE KOHA API DAEMON + Alias /v1/doc __INTRANET_CGI_DIR__/api/v1/doc + Alias /v1/swagger.json "__INTRANET_CGI_DIR__/api/v1/swagger.json" + + ProxyRequests Off #Disable anonymous forward proxying + ProxyPreserveHost On + ProxyPass /v1/doc ! + ProxyPass /v1/swagger.json ! + ProxyPass /v1/ http://localhost:8081/v1/ keepalive=On + ProxyPassReverse /v1/ http://localhost:8081/v1/ + ##REVERSE PROXYING OK + Options -Indexes @@ -144,6 +156,18 @@ ErrorDocument 404 /cgi-bin/koha/errors/404.pl ErrorDocument 500 /cgi-bin/koha/errors/500.pl + ##REVERSE PROXY REQUESTS TO THE KOHA API DAEMON + Alias /v1/doc __INTRANET_CGI_DIR__/api/v1/doc + Alias /v1/swagger.json "__INTRANET_CGI_DIR__/api/v1/swagger.json" + + ProxyRequests Off #Disable anonymous forward proxying + ProxyPreserveHost On + ProxyPass /v1/doc ! + ProxyPass /v1/swagger.json ! + ProxyPass /v1/ http://localhost:8081/v1/ keepalive=On + ProxyPassReverse /v1/ http://localhost:8081/v1/ + ##REVERSE PROXYING OK + Options -Indexes @@ -216,22 +240,3 @@ RewriteRule ^/issn/([^\/]*)/?$ /search?q=issn:$1 [PT] - - - ServerAdmin __WEBMASTER_EMAIL__ - DocumentRoot __INTRANET_CGI_DIR__/api - ServerName api.__WEBSERVER_HOST__:__WEBSERVER_PORT__ - SetEnv KOHA_CONF "__KOHA_CONF_DIR__/koha-conf.xml" - SetEnv PERL5LIB "__PERL_MODULE_DIR__" - - - Options +ExecCGI +FollowSymlinks - AddHandler cgi-script .cgi - - RewriteEngine on - RewriteCond %{REQUEST_FILENAME} !-f - RewriteCond %{REQUEST_FILENAME} !-d - RewriteCond %{DOCUMENT_ROOT}/$1/script.cgi -f - RewriteRule ^(.*?)/.* $1/script.cgi/$0 [L] - - -- 1.9.1