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