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