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