Bug 20187: (QA follow-up) Replace N,L flag by L flag
[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       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][0-9]\.[0-9][0-9][0-9][0-9][0-9][0-9][0-9].js$ $1.js [L]
115      RewriteRule ^(.*)_[0-9][0-9]\.[0-9][0-9][0-9][0-9][0-9][0-9][0-9].css$ $1.css [L]
116
117      # REST API configuration
118      Alias "/api" "__API_CGI_DIR__"
119      <Directory __API_CGI_DIR__>
120        Options +ExecCGI +FollowSymlinks
121        AddHandler cgi-script .pl
122
123        SetEnv MOJO_MODE "production"
124
125        RewriteEngine On
126        RewriteBase /api/
127        RewriteCond %{REQUEST_FILENAME} !-f
128        RewriteCond %{REQUEST_FILENAME} !-d
129        RewriteCond %{DOCUMENT_ROOT}/../api/$1/app.pl -f
130        RewriteRule ^(.*?)/.* $1/app.pl/api/$0 [L]
131      </Directory>
132    </IfModule>
133
134    <IfModule mod_expires.c>
135       ExpiresActive on
136       ExpiresByType text/css "access plus 60 days"
137       ExpiresByType application/javascript "access plus 60 days"
138       ExpiresByType image/png "access plus 12 hours"
139       ExpiresByType image/gif "access plus 12 hours"
140    </IfModule>
141 </VirtualHost>
142
143 ## Intranet
144 <VirtualHost __WEBSERVER_IP__:__WEBSERVER_PORT_LIBRARIAN__>
145    ServerAdmin __WEBMASTER_EMAIL__
146    DocumentRoot __INTRANET_WWW_DIR__
147    ServerName __WEBSERVER_HOST__:__WEBSERVER_PORT_LIBRARIAN__
148 #  ServerAlias intranet.mydomain.com
149    ScriptAlias /cgi-bin/koha/ "__INTRANET_CGI_DIR__/"
150    ScriptAlias /index.html "__INTRANET_CGI_DIR__/mainpage.pl"
151    ScriptAlias /search "__INTRANET_CGI_DIR__/catalogue/search.pl"
152    Alias /plugin/ "__PLUGINS_DIR__/"
153    ErrorLog __LOG_DIR__/koha-error_log
154 #  TransferLog __LOG_DIR__/koha-access.log
155    SetEnv KOHA_CONF "__KOHA_CONF_DIR__/koha-conf.xml"
156    SetEnv PERL5LIB "__PERL_MODULE_DIR__"
157    Options +FollowSymLinks
158
159    # If you are overriding any system preferences,
160    # list them in this variable so the preference editor
161    # knows that they have been overridden.
162    # SetEnv OVERRIDE_SYSPREF_NAMES "Pref1,Pref2,Pref3"
163
164    ErrorDocument 400 /cgi-bin/koha/errors/400.pl
165    ErrorDocument 401 /cgi-bin/koha/errors/401.pl
166    ErrorDocument 403 /cgi-bin/koha/errors/403.pl
167    ErrorDocument 404 /cgi-bin/koha/errors/404.pl
168    ErrorDocument 500 /cgi-bin/koha/errors/500.pl
169
170    <Directory "__INTRANET_WWW_DIR__">
171       Options -Indexes
172    </Directory>
173
174    # Secure internal stuff
175    <DirectoryMatch "__INTRANET_WWW_DIR__/.*/(modules|xslt|includes)">
176       Order deny,allow
177       Deny from all
178    </DirectoryMatch>
179
180    <IfModule mod_gzip.c>
181      mod_gzip_on yes
182      mod_gzip_dechunk yes
183      mod_gzip_keep_workfiles No
184      mod_gzip_can_negotiate yes
185      mod_gzip_update_static No
186      mod_gzip_temp_dir /tmp
187      mod_gzip_minimum_file_size 512
188      mod_gzip_maximum_file_size 1000000
189      mod_gzip_maximum_inmem_size 1000000
190      mod_gzip_handle_methods GET POST
191      mod_gzip_item_exclude reqheader "User-Agent: .*Mozilla/4\..*\["
192      mod_gzip_item_exclude mime ^image/.*
193      mod_gzip_item_exclude rspheader Content-Type:image/*
194      mod_gzip_item_include file \.js$
195      mod_gzip_item_include mime ^application/javascript$
196      mod_gzip_item_include mime ^application/x-javascript$
197      mod_gzip_item_include file \.php$
198      mod_gzip_item_include mime ^text/html$
199      mod_gzip_item_include file \.css$
200      mod_gzip_item_include mime ^text/css$
201    </IfModule>
202
203    <IfModule mod_deflate.c>
204
205      # Compress content with type html, text, and css, ...
206      AddOutputFilterByType DEFLATE text/plain text/html text/xml text/css
207      AddOutputFilterByType DEFLATE application/xml application/xhtml+xml application/rss+xml application/javascript application/x-javascript
208
209      DeflateCompressionLevel 9
210
211      # Properly handle old browsers that do not support compression
212      BrowserMatch ^Mozilla/4 gzip-only-text/html
213      BrowserMatch ^Mozilla/4\.0[678] no-gzip
214      BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
215
216      DeflateFilterNote Input instream
217      DeflateFilterNote Output outstream
218      DeflateFilterNote Ratio ratio
219
220      LogFormat '"%r" %{outstream}n/%{instream}n (%{ratio}n%%)' deflate
221      <IfModule mod_headers.c>
222        #properly handle requests coming from behind proxies
223        Header append Vary User-Agent
224      </IfModule>
225   </IfModule>
226
227    <IfModule mod_rewrite.c>
228      # Rewrite Rules
229      RewriteEngine On
230
231      # Uncomment to turn on rewrite logging
232      #RewriteLog __LOG_DIR__/koha-intranet-rewrite.log
233      #RewriteLogLevel 1
234
235      #The following two directives are unnecessary to proper Koha functioning.
236      #RewriteCond %{QUERY_STRING} (.*?)(?:[A-Za-z0-9_-]+)=&(.*)
237      #RewriteRule (.+) $1?%1%2 [N,R,NE]
238      RewriteRule ^/bib/([^\/]*)/?$ /cgi-bin/koha/detail\.pl?bib=$1 [PT]
239      RewriteRule ^/isbn/([^\/]*)/?$ /search?q=isbn:$1 [PT]
240      RewriteRule ^/issn/([^\/]*)/?$ /search?q=issn:$1 [PT]
241      RewriteRule ^(.*)_[0-9][0-9]\.[0-9][0-9][0-9][0-9][0-9][0-9][0-9].js$ $1.js [L]
242      RewriteRule ^(.*)_[0-9][0-9]\.[0-9][0-9][0-9][0-9][0-9][0-9][0-9].css$ $1.css [L]
243
244
245      # REST API configuration
246      Alias "/api" "__API_CGI_DIR__"
247      <Directory __API_CGI_DIR__>
248        Options +ExecCGI +FollowSymlinks
249        AddHandler cgi-script .pl
250
251        SetEnv MOJO_MODE "production"
252
253        RewriteEngine On
254        RewriteBase /api/
255        RewriteCond %{REQUEST_FILENAME} !-f
256        RewriteCond %{REQUEST_FILENAME} !-d
257        RewriteCond %{DOCUMENT_ROOT}/../api/$1/app.pl -f
258        RewriteRule ^(.*?)/.* $1/app.pl/api/$0 [L]
259      </Directory>
260    </IfModule>
261
262    <IfModule mod_expires.c>
263       ExpiresActive on
264       ExpiresByType text/css "access plus 60 days"
265       ExpiresByType application/javascript "access plus 60 days"
266       ExpiresByType image/png "access plus 12 hours"
267       ExpiresByType image/gif "access plus 12 hours"
268    </IfModule>
269 </VirtualHost>
270
271 # Uncomment this VirtualHost to enable API access through
272 # api.__WEBSERVER_HOST__:__WEBSERVER_PORT__
273 #<VirtualHost __WEBSERVER_IP__:__WEBSERVER_PORT__>
274 #  ServerAdmin __WEBMASTER_EMAIL__
275 #  DocumentRoot __INTRANET_CGI_DIR__/api
276 #  ServerName api.__WEBSERVER_HOST__:__WEBSERVER_PORT__
277 #  SetEnv KOHA_CONF "__KOHA_CONF_DIR__/koha-conf.xml"
278 #  SetEnv PERL5LIB "__PERL_MODULE_DIR__"
279 #  ErrorLog __LOG_DIR__/koha-api-error_log
280 #
281 #  <IfModule mod_rewrite.c>
282 #    <Directory __API_CGI_DIR__>
283 #      Options +ExecCGI +FollowSymlinks
284 #      AddHandler cgi-script .pl
285 #
286 #      SetEnv MOJO_MODE "production"
287 #
288 #      RewriteEngine on
289 #
290 #      RewriteRule ^api/(.*) $1 [L]
291 #
292 #      RewriteCond %{REQUEST_FILENAME} !-f
293 #      RewriteCond %{REQUEST_FILENAME} !-d
294 #      RewriteCond %{DOCUMENT_ROOT}/$1/app.pl -f
295 #      RewriteRule ^(.*?)/.* $1/app.pl/api/$0 [L]
296 #    </Directory>
297 #  </IfModule>
298 #</VirtualHost>