From 7955e65c9b154ce962d0423af18673d58d9d0b0a Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Thu, 4 Aug 2016 12:47:13 -0300 Subject: [PATCH] Bug 17030: (followup) Rewrite rule for Plack This patch fixes the TODO from the previous one. It implements the rewrite on the Plack-related files so pretty uRLs can be used. To test: - Follow the previous patches test steps (you should have a tweaked plack-psgi file and Plack enabled) - Grab debian/templates/apache-shared-opac-plack.conf debian/templates/apache-shared-intranet-plack.conf and put them in /etc/koha - Run: $ sudo service apache2 restart - Point your browser to: http://localhost:8080/api/v1/app.pl/api/v1/patrons/50 => SUCCESS: You get the JSON output from the REST api - Point your browser to the pretty URL: http://localhost:8080/api/v1/patrons/50 => SUCCESS: You get the JSON output from the REST api - Repeat for port 8081 (intranet) - Sign off :-D --- debian/templates/apache-shared-intranet-plack.conf | 2 ++ debian/templates/apache-shared-opac-plack.conf | 2 ++ 2 files changed, 4 insertions(+) diff --git a/debian/templates/apache-shared-intranet-plack.conf b/debian/templates/apache-shared-intranet-plack.conf index b544958..9da1240 100644 --- a/debian/templates/apache-shared-intranet-plack.conf +++ b/debian/templates/apache-shared-intranet-plack.conf @@ -24,6 +24,8 @@ # RequestHeader set X-FORWARDED-PROTO "https" # Point the intranet site to Plack + RewriteRule ^/api/(v[0-9]+)/(.*)$ /api/$1/app.pl/api/$1/$2 [L,PT] + 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" diff --git a/debian/templates/apache-shared-opac-plack.conf b/debian/templates/apache-shared-opac-plack.conf index 6a4b3b0..1850a0e 100644 --- a/debian/templates/apache-shared-opac-plack.conf +++ b/debian/templates/apache-shared-opac-plack.conf @@ -18,6 +18,8 @@ ProxyPassReverse /cgi-bin/koha "unix:/var/run/koha/${instance}/plack.sock|http://localhost/opac" # Point the /api endpoint to Plack + 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" -- 2.9.2