Bug 13799: RESTful API with Mojolicious and Swagger2
[koha.git] / etc / koha-httpd.conf
1 # Koha Apache Configuration Directives
2
3 #NameVirtualHost *
4
5 ## OPAC
6 <VirtualHost __WEBSERVER_IP__:__WEBSERVER_PORT__>
7    ServerAdmin  __WEBMASTER_EMAIL__
8    DocumentRoot __OPAC_WWW_DIR__
9    ServerName __WEBSERVER_HOST__
10 #  ServerAlias opac.mydomain.com
11    ScriptAlias /cgi-bin/koha/ "__OPAC_CGI_DIR__/opac/"
12    ScriptAlias /index.html "__OPAC_CGI_DIR__/opac/opac-main.pl"
13    ScriptAlias /opac-search.pl "__OPAC_CGI_DIR__/opac/opac-search.pl"
14    ScriptAlias /search "__OPAC_CGI_DIR__/opac/opac-search.pl"
15    ErrorLog __LOG_DIR__/koha-opac-error_log
16 #  CustomLog __LOG_DIR__/koha-opac-access.log combined
17 #  TransferLog __LOG_DIR__/koha-opac-access.log
18    SetEnv KOHA_CONF "__KOHA_CONF_DIR__/koha-conf.xml"
19    SetEnv PERL5LIB "__PERL_MODULE_DIR__"
20    SetEnv MEMCACHED_SERVERS "__MEMCACHED_SERVERS__"
21    SetEnv MEMCACHED_NAMESPACE "__MEMCACHED_NAMESPACE__"
22
23    # This syntax allows you to override a system preference
24    # for a given virtual host. Use with caution!
25    # You should add all the system preferences you override
26    # in one or more vhosts to the environment variable
27    # OVERRIDE_SYSPREF_NAMES for your staff intranet vhost
28    # SetEnv OVERRIDE_SYSPREF_PrefName Value
29
30    <Directory "__OPAC_WWW_DIR__">
31       Options -Indexes
32    </Directory>
33
34    # Secure internal stuff
35    <DirectoryMatch "__OPAC_WWW_DIR__/.*/(modules|xslt|includes)">
36       Order deny,allow
37       Deny from all
38    </DirectoryMatch>
39
40    <IfModule mod_gzip.c>
41      mod_gzip_on yes
42      mod_gzip_dechunk yes
43      mod_gzip_keep_workfiles No
44      mod_gzip_can_negotiate yes
45      mod_gzip_update_static No
46      mod_gzip_temp_dir /tmp
47      mod_gzip_minimum_file_size 512
48      mod_gzip_maximum_file_size 1000000
49      mod_gzip_maximum_inmem_size 1000000
50      mod_gzip_handle_methods GET POST
51      mod_gzip_item_exclude reqheader "User-Agent: .*Mozilla/4\..*\["
52      mod_gzip_item_exclude mime ^image/.*
53      mod_gzip_item_exclude rspheader Content-Type:image/*
54      mod_gzip_item_include file \.js$
55      mod_gzip_item_include mime ^application/javascript$
56      mod_gzip_item_include mime ^application/x-javascript$
57      mod_gzip_item_include file \.php$
58      mod_gzip_item_include mime ^text/html$
59      mod_gzip_item_include file \.css$
60      mod_gzip_item_include mime ^text/css$
61   </IfModule>
62
63   <IfModule mod_deflate.c>
64
65     # Compress content with type html, text, and css, ...
66     AddOutputFilterByType DEFLATE text/plain text/html text/xml text/css
67     AddOutputFilterByType DEFLATE application/xml application/xhtml+xml application/rss+xml application/javascript application/x-javascript
68
69     DeflateCompressionLevel 9
70
71     # Properly handle old browsers that do not support compression
72     BrowserMatch ^Mozilla/4 gzip-only-text/html
73     BrowserMatch ^Mozilla/4\.0[678] no-gzip
74     BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
75
76     DeflateFilterNote Input instream
77     DeflateFilterNote Output outstream
78     DeflateFilterNote Ratio ratio
79
80     LogFormat '"%r" %{outstream}n/%{instream}n (%{ratio}n%%)' deflate
81     <IfModule mod_headers.c>
82        #properly handle requests coming from behind proxies
83        Header append Vary User-Agent
84     </IfModule>
85   </IfModule>
86
87
88 #  Repeat this virtualhost stanza changing the following environment vars to
89 #  create multiple OPAC interfaces with custom css and/or search limits:
90 #  SetEnv OPAC_CSS_OVERRIDE mystyle.css
91 #  SetEnv OPAC_SEARCH_LIMIT branch:CODE
92 #  SetEnv OPAC_LIMIT_OVERRIDE 1
93
94    Options +FollowSymLinks
95
96    ErrorDocument 400 /cgi-bin/koha/errors/400.pl
97    ErrorDocument 401 /cgi-bin/koha/errors/401.pl
98    ErrorDocument 403 /cgi-bin/koha/errors/403.pl
99    ErrorDocument 404 /cgi-bin/koha/errors/404.pl
100    ErrorDocument 500 /cgi-bin/koha/errors/500.pl
101
102    <IfModule mod_rewrite.c>
103      # Rewrite Rules
104      RewriteEngine On
105
106      # Uncomment to turn on rewrite logging
107      #RewriteLog __LOG_DIR__/koha-opac-rewrite.log
108      #RewriteLogLevel 1
109
110      RewriteCond %{QUERY_STRING} (.*?)(?:[A-Za-z0-9_-]+)=&(.*)
111      #RewriteRule (.+) $1?%1%2 [N,R,NE]
112      RewriteRule ^/bib/([^\/]*)/?$ /cgi-bin/koha/opac-detail\.pl?bib=$1 [PT]
113      RewriteRule ^/isbn/([^\/]*)/?$ /search?q=isbn:$1 [PT]
114      RewriteRule ^/issn/([^\/]*)/?$ /search?q=issn:$1 [PT]
115
116      # REST API configuration
117      Alias "/api" "__OPAC_CGI_DIR__/api"
118      <Directory __OPAC_CGI_DIR__/api>
119        Options +ExecCGI +FollowSymlinks
120        AddHandler cgi-script .pl
121
122        RewriteEngine On
123        RewriteBase /api/
124        RewriteCond %{REQUEST_FILENAME} !-f
125        RewriteCond %{REQUEST_FILENAME} !-d
126        RewriteCond %{DOCUMENT_ROOT}/../api/$1/app.pl -f
127        RewriteRule ^(.*?)/.* $1/app.pl/api/$0 [L]
128      </Directory>
129    </IfModule>
130 </VirtualHost>
131
132 ## Intranet
133 <VirtualHost __WEBSERVER_IP__:__WEBSERVER_PORT_LIBRARIAN__>
134    ServerAdmin __WEBMASTER_EMAIL__
135    DocumentRoot __INTRANET_WWW_DIR__
136    ServerName __WEBSERVER_HOST__:__WEBSERVER_PORT_LIBRARIAN__
137 #  ServerAlias intranet.mydomain.com
138    ScriptAlias /cgi-bin/koha/ "__INTRANET_CGI_DIR__/"
139    ScriptAlias /index.html "__INTRANET_CGI_DIR__/mainpage.pl"
140    ScriptAlias /search "__INTRANET_CGI_DIR__/search.pl"
141    Alias /plugin/ "__PLUGINS_DIR__/"
142    ErrorLog __LOG_DIR__/koha-error_log
143 #  TransferLog __LOG_DIR__/koha-access.log
144    SetEnv KOHA_CONF "__KOHA_CONF_DIR__/koha-conf.xml"
145    SetEnv PERL5LIB "__PERL_MODULE_DIR__"
146    SetEnv MEMCACHED_SERVERS "__MEMCACHED_SERVERS__"
147    SetEnv MEMCACHED_NAMESPACE "__MEMCACHED_NAMESPACE__"
148    Options +FollowSymLinks
149
150    # If you are overriding any system preferences,
151    # list them in this variable so the preference editor
152    # knows that they have been overridden.
153    # SetEnv OVERRIDE_SYSPREF_NAMES "Pref1,Pref2,Pref3"
154
155    ErrorDocument 400 /cgi-bin/koha/errors/400.pl
156    ErrorDocument 401 /cgi-bin/koha/errors/401.pl
157    ErrorDocument 403 /cgi-bin/koha/errors/403.pl
158    ErrorDocument 404 /cgi-bin/koha/errors/404.pl
159    ErrorDocument 500 /cgi-bin/koha/errors/500.pl
160
161    <Directory "__INTRANET_WWW_DIR__">
162       Options -Indexes
163    </Directory>
164
165    # Secure internal stuff
166    <DirectoryMatch "__INTRANET_WWW_DIR__/.*/(modules|xslt|includes)">
167       Order deny,allow
168       Deny from all
169    </DirectoryMatch>
170
171    <IfModule mod_gzip.c>
172      mod_gzip_on yes
173      mod_gzip_dechunk yes
174      mod_gzip_keep_workfiles No
175      mod_gzip_can_negotiate yes
176      mod_gzip_update_static No
177      mod_gzip_temp_dir /tmp
178      mod_gzip_minimum_file_size 512
179      mod_gzip_maximum_file_size 1000000
180      mod_gzip_maximum_inmem_size 1000000
181      mod_gzip_handle_methods GET POST
182      mod_gzip_item_exclude reqheader "User-Agent: .*Mozilla/4\..*\["
183      mod_gzip_item_exclude mime ^image/.*
184      mod_gzip_item_exclude rspheader Content-Type:image/*
185      mod_gzip_item_include file \.js$
186      mod_gzip_item_include mime ^application/javascript$
187      mod_gzip_item_include mime ^application/x-javascript$
188      mod_gzip_item_include file \.php$
189      mod_gzip_item_include mime ^text/html$
190      mod_gzip_item_include file \.css$
191      mod_gzip_item_include mime ^text/css$
192    </IfModule>
193
194    <IfModule mod_deflate.c>
195
196      # Compress content with type html, text, and css, ...
197      AddOutputFilterByType DEFLATE text/plain text/html text/xml text/css
198      AddOutputFilterByType DEFLATE application/xml application/xhtml+xml application/rss+xml application/javascript application/x-javascript
199
200      DeflateCompressionLevel 9
201
202      # Properly handle old browsers that do not support compression
203      BrowserMatch ^Mozilla/4 gzip-only-text/html
204      BrowserMatch ^Mozilla/4\.0[678] no-gzip
205      BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
206
207      DeflateFilterNote Input instream
208      DeflateFilterNote Output outstream
209      DeflateFilterNote Ratio ratio
210
211      LogFormat '"%r" %{outstream}n/%{instream}n (%{ratio}n%%)' deflate
212      <IfModule mod_headers.c>
213        #properly handle requests coming from behind proxies
214        Header append Vary User-Agent
215      </IfModule>
216   </IfModule>
217
218    <IfModule mod_rewrite.c>
219      # Rewrite Rules
220      RewriteEngine On
221
222      # Uncomment to turn on rewrite logging
223      #RewriteLog __LOG_DIR__/koha-intranet-rewrite.log
224      #RewriteLogLevel 1
225
226      RewriteCond %{QUERY_STRING} (.*?)(?:[A-Za-z0-9_-]+)=&(.*)
227      #RewriteRule (.+) $1?%1%2 [N,R,NE]
228      RewriteRule ^/bib/([^\/]*)/?$ /cgi-bin/koha/detail\.pl?bib=$1 [PT]
229      RewriteRule ^/isbn/([^\/]*)/?$ /search?q=isbn:$1 [PT]
230      RewriteRule ^/issn/([^\/]*)/?$ /search?q=issn:$1 [PT]
231
232
233      # REST API configuration
234      Alias "/api" "__INTRANET_CGI_DIR__/api"
235      <Directory __INTRANET_CGI_DIR__/api>
236        Options +ExecCGI +FollowSymlinks
237        AddHandler cgi-script .pl
238
239        RewriteEngine On
240        RewriteBase /api/
241        RewriteCond %{REQUEST_FILENAME} !-f
242        RewriteCond %{REQUEST_FILENAME} !-d
243        RewriteCond %{DOCUMENT_ROOT}/../api/$1/app.pl -f
244        RewriteRule ^(.*?)/.* $1/app.pl/api/$0 [L]
245      </Directory>
246    </IfModule>
247 </VirtualHost>
248
249 # Uncomment this VirtualHost to enable API access through
250 # api.__WEBSERVER_HOST__:__WEBSERVER_PORT__
251 #<VirtualHost __WEBSERVER_IP__:__WEBSERVER_PORT__>
252 #  ServerAdmin __WEBMASTER_EMAIL__
253 #  DocumentRoot __INTRANET_CGI_DIR__/api
254 #  ServerName api.__WEBSERVER_HOST__:__WEBSERVER_PORT__
255 #  SetEnv KOHA_CONF "__KOHA_CONF_DIR__/koha-conf.xml"
256 #  SetEnv PERL5LIB "__PERL_MODULE_DIR__"
257 #  ErrorLog __LOG_DIR__/koha-api-error_log
258 #
259 #  <IfModule mod_rewrite.c>
260 #    <Directory __INTRANET_CGI_DIR__/api>
261 #      Options +ExecCGI +FollowSymlinks
262 #      AddHandler cgi-script .pl
263 #
264 #      RewriteEngine on
265 #
266 #      RewriteRule ^api/(.*) $1 [L]
267 #
268 #      RewriteCond %{REQUEST_FILENAME} !-f
269 #      RewriteCond %{REQUEST_FILENAME} !-d
270 #      RewriteCond %{DOCUMENT_ROOT}/$1/app.pl -f
271 #      RewriteRule ^(.*?)/.* $1/app.pl/api/$0 [L]
272 #    </Directory>
273 #  </IfModule>
274 #</VirtualHost>