root/CPS3/products/CPSDefault/trunk/doc/howto-virtual_hosts.txt

Revision 52890, 22.5 kB (checked in by madarche, 2 years ago)

Added a reference on the new CPSApacheProxyBalancer product.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
Line 
1 ===========================================================
2 HOWTO to setup CPS with Apache httpd VirtualHost directives
3 ===========================================================
4
5 :Author: Marc-Aurèle Darche
6
7 :Revision: $Id$
8
9 .. sectnum::    :depth: 4
10 .. contents::   :depth: 4
11
12
13 Introduction
14 ============
15
16 Apache httpd different flavors
17 ------------------------------
18
19 .. _CPS: http://www.cps-project.org/
20 .. _Zope: http://www.zope.org/
21 .. _Apache httpd: http://httpd.apache.org/
22 .. _reverse proxy: http://en.wikipedia.org/wiki/Reverse_proxy
23
24 This document explains how to setup CPS_ behind
25 the `Apache httpd`_ server through
26 the `reverse proxy`_ technique.
27
28 This kind of configuration is the preferred way to deploy CPS web sites because:
29
30 - Apache httpd is very fast and can handle a web cache.
31
32 - Apache httpd supports the ability to have parts of CPS web sites
33   protected through HTTPS.
34
35 - Apache httpd supports the ability to combine many web sites and
36   many technologies together (CPS_, Zope_, PHP, CGI, Perl, Java,
37   etc.) together behind a single domain name.
38
39 The Apache httpd server comes in different series (the 1.3.x and the 2.x series,
40 etc.) and also in different versions (the standard httpd version and the
41 Apache-SSL flavor).
42
43 In this document we will only explain the use of the following
44 versions:
45
46 - Apache httpd 2.x (usually called Apache2)
47
48 - Apache-ssl
49
50 Using Apache 2 is the preferred option because it is the more
51 up-to-date version and the version on which development is done.
52 Apache-ssl was only handy before Apache 2. But now that Apache 2
53 ships with mod_ssl by default, there isn't' any reason to stay
54 with Apache-SSL anymore.
55
56
57 Adapting the examples to your needs
58 -----------------------------------
59
60 .. _Debian: http://www.debian.org/
61 .. _Ubuntu: http://www.ubuntu.com/
62 .. _Plone: http://plone.org/
63
64 This howto presents configurations for Debian_ 3.1 "Sarge"
65 systems and should work on any Debian_ based systems (Ubuntu_, etc.).
66
67 Port 9673 is the Zope default port on Debian. You might have to
68 change it to 8080 depending on your configuration.
69
70 In the following examples ``machine.localdomain`` can be replaced by
71 ``localhost`` if your Zope server runs on the same machine as your Apache httpd
72 server.
73
74 Finally note that while this howto focuses on CPS, the most complete Open Source
75 solution available for building Enterprise Content Management (ECM)
76 applications, it could advantageously be followed for other Zope-based
77 applications such as Plone_.
78
79
80 Using Apache 2
81 ==============
82
83 Here are some configuration examples using Apache2 httpd
84 VirtualHost directives.
85
86 Prerequisites
87 -------------
88
89 What you need:
90
91 1. ::
92
93      $ apt-get install apache2
94
95 2. Enable the following modules: proxy, rewrite, ssl
96
97    On a Debian system it is done by calling the commands::
98
99      $ a2enmod proxy
100      $ a2enmod rewrite
101      $ a2enmod ssl
102
103    On a Debian system with Apache 2.2 (typically Debian Etch) you might get the
104    following error message::
105
106      proxy: No protocol handler was valid for the URL /. If you are using a DSO version of mod_proxy, make sure the proxy submodules are included in the configuration using LoadModule.
107
108    In this case the following module should also be enabled::
109
110      $ a2enmod proxy_http
111
112 3. Open the needed ports in ``/etc/apache2/ports.conf``::
113
114      Listen 80
115      Listen 443
116      Listen 453
117
118 4. Authorize proxy requests in ``/etc/apache2/mods-enabled/proxy.conf``
119    otherwise you could end up with an unreachable CPS web site and
120    messages like
121    ``client denied by server configuration: proxy:http://localhost``
122    in your log files::
123
124      <Proxy *>
125        Order deny,allow
126        Deny from all
127      </Proxy>
128
129      <Proxy http://localhost:9673>
130        Order deny,allow
131        Deny from all
132        Allow from all
133      </Proxy>
134
135 5. If you want to use HTTPS for your web server you should either:
136
137    - generate a single self-signed certificate (this is the easy way to go if
138      you just want HTTPS for one portal and don't care about flexibility,
139      evolution, multiple service or domain names on the same machine, etc.)
140
141    - generate a private key and certificate file (this is the more serious and
142      flexible way to go)
143
144    We will only document the single self-signed certificate generation procedure
145    that can easily be use on Debian systems. This documentation is not about
146    teaching you how to manipulate certificates or installing/using a PKI.
147
148    On Debian-based systems there is a small utility that can generate the
149    self-signed certificate for you: ``apache2-ssl-certificate``::
150
151      $ /usr/sbin/apache2-ssl-certificate
152
153    Just answer the few questions (Country Name, server name, Email Address,
154    etc.) about your service name or portal name and machine
155    and it will generate the certificate for you in
156    ``/etc/apache2/ssl/apache.pem``.
157
158    If you are not satisfied with the questions asked by the utility (for example
159    to get rid of the stupid `State or Province Name` information and the
160    localityName information) edit the OpenSSL configuration file used by Apache
161    before running the utility::
162
163      [ req_distinguished_name ]
164      countryName                     = Country Name (2 letter code)
165      # You can change the default values
166      #countryName_default             = GB
167      countryName_default             = FR
168      countryName_min                 = 2
169      countryName_max                 = 2
170
171      # Just comment out the option you don't want to have to be set
172      #stateOrProvinceName             = State or Province Name (full name)
173      #stateOrProvinceName_default     = Some-State
174
175      # Just comment out the option you don't want to have to be set
176      #localityName                    = Locality Name (eg, city)
177
178      organizationName                = Organization Name (eg, company; recommended)
179      organizationName_max            = 64
180
181      organizationalUnitName          = Organizational Unit Name (eg, section)
182      organizationalUnitName_max      = 64
183
184      commonName                      = server name (eg. ssl.domain.tld; required!!!)
185      commonName_max                  = 64
186
187      emailAddress                    = Email Address
188      emailAddress_max                = 40
189
190
191    Then you can check the information that ended in the certificate::
192
193      $ openssl x509 -in /etc/apache2/ssl/apache.pem -text
194
195      Certificate:
196          Data:
197              Version: 1 (0x0)
198              Serial Number:
199                  a0:35:f0:c7:d1:68:5a:27
200              Signature Algorithm: md5WithRSAEncryption
201              Issuer: C=FR, O=MySite, CN=www.mysite.net/emailAddress=webmaster@mysite.net
202              Validity
203                  Not Before: May 18 13:15:45 2006 GMT
204                  Not After : Jun 17 13:15:45 2006 GMT
205              Subject: C=FR, O=MySite, CN=www.mysite.net/emailAddress=webmaster@mysite.net
206              Subject Public Key Info:
207                  Public Key Algorithm: rsaEncryption
208                  RSA Public Key: (1024 bit)
209                      Modulus (1024 bit):
210                          00:cb:4c:6e:69:91:b4:70:d2:55:80:15:fe:34:e9:
211                          85:df:74:56:6a:6c:de:15:f6:b3:ba:78:b8:06:74:
212                          b4:d3:c6:35:cf:6c:8d:21:7b:53:0e:b1:c9:24:51:
213                          bc:23:9f:bd:c5:b1:07:5a:30:34:5a:97:e8:4c:d5:
214                          5f:83:24:7e:3b:d9:9d:07:bd:d3:ca:4d:a4:f7:4b:
215                          d2:49:c2:63:6d:4e:3e:82:58:91:b6:45:2f:80:61:
216                          c2:a1:6e:10:e8:1d:21:b7:f9:e2:0e:b6:95:24:dd:
217                          ae:82:9c:6c:3e:38:ac:ca:cb:e2:74:fc:65:97:85:
218                          40:39:3d:ee:81:16:db:57:8f
219                      Exponent: 65537 (0x10001)
220          Signature Algorithm: md5WithRSAEncryption
221              5a:6e:6e:b0:82:aa:b6:71:42:24:b8:d5:31:6a:78:13:81:a2:
222              dc:c3:91:91:e5:20:46:b5:91:81:11:f6:bc:86:4e:e2:a5:bd:
223              d9:b8:c1:ca:16:a1:46:de:4e:69:bf:7a:dd:5e:24:dd:d6:53:
224              12:12:23:75:bd:e2:45:ad:81:7f:8f:82:35:20:ce:68:69:71:
225              50:ea:45:8f:4b:fe:f4:be:84:53:4d:2b:7d:85:5b:bd:0d:8f:
226              6b:66:2a:87:9e:41:94:ee:44:01:ae:76:45:ad:e9:a1:71:fd:
227              6f:1d:96:d3:53:66:d1:a7:96:97:54:ac:43:b1:78:77:90:a1:
228              ac:aa
229      -----BEGIN CERTIFICATE-----
230      GhxeGTCCAaYCCQCgNfDH0WhaJzANBgkqhkiG9w0BAQQFADBjMQswCQYDVQQGEwJG
231      UjEOMAwGA1UEChMFTW9udW0xHjAcBgNVBAMTFXd3dy5pbnRyYW5ldC5tb251bS5m
232      cjEkMCIGCSqGSIb3DQEJARYVY29tLmludHJhbmV0QG1vbnVtLmZyMB4XDTA2MDUx
233      ODEzMTU0NVoXDTA2MDYxNzEzMTU0NVowYzELMAkGA1UEBhMCRlIxDjAMBgNVBAoT
234      BU1vbnVtMR4wHAYDVQQDExV3d3ergeg,melrGERGRG9udW0uZnIxJDAiBgkqhkiG
235      9w0BCQEWFWNvbS5pbnRyYW5ldEBtb251bS5mcjCBnzANBgkqhkiG9w0BAQEFAAOB
236      jQAwgYkCgYEAy0xuaZG0cNJVgBX+NOmF33RWamzeFfazuni4BnS008Y1z2yNIXtT
237      DrHJJFG8I5+9xbEHWjA0WpfoTNVfgyR+O9mdB73Tyk2k90vSScJjbU4+gliRtkUv
238      gGHCoW4Q6B0ht/niDraVJN2ugpxsPjisysvidPxll4VAOT3ugRbbV48CAwEAATAN
239      BgkqhkiG9w0BAQQFAAOBgQBabm6wgqq2cUIkuNUxangTgaLcw5GR5SBGtZGBEfa8
240      hk7ipb3ZuMHKFqFG3k5pv3rdXiTd1lMSEiN1veJFrYF/j4I1IM5oaXFQ6kWPS/70
241      voRTTSt9hVu9DY9rZiqHnkGU7kQBrnZFremhcf1vHZbTU2bRp5aXVKxDsXgrA3Gs
242      qg==
243      -----END CERTIFICATE-----
244
245
246 Simple virtual host HTTP + HTTPS configuration
247 ----------------------------------------------
248
249 This configuration is what most people would need. This is not a secure
250 configuration, but it is easy to setup and understand.
251
252 Example::
253
254   <VirtualHost 192.168.2.20:80>
255   ServerName www.mysite.net
256
257   RewriteEngine on
258
259   RewriteCond %{HTTP:Authorization}  ^(.*)
260   RewriteRule ^/(.*) http://machine.localdomain:9673/VirtualHostBase/http/%{HTTP_HOST}:80/cps/VirtualHostRoot/$1 [P,L]
261
262   CustomLog /var/log/apache2/www.mysite.net.log combined
263   ErrorLog /var/log/apache2/www.mysite.net-error.log
264   </VirtualHost>
265
266   <VirtualHost 192.168.2.20:443>
267   ServerName www.mysite.net
268
269   SSLEngine on
270   SSLCertificateFile /etc/apache2/ssl/apache.pem
271   # Alternatively use those lines for private key and certificate configurations
272   #SSLCertificateFile /etc/apache2/ssl/www.mysite.net.cert
273   #SSLCertificateKeyFile /etc/apache2/ssl/www.mysite.net.key
274
275   RewriteEngine on
276
277   RewriteCond %{HTTP:Authorization}  ^(.*)
278   RewriteRule ^/(.*)  http://machine.localdomain:9673/VirtualHostBase/https/%{HTTP_HOST}:443/cps/VirtualHostRoot/$1 [P,L]
279
280   CustomLog /var/log/apache2/www.mysite.net.log combined
281   ErrorLog /var/log/apache2/www.mysite.net-error.log
282   </VirtualHost>
283
284
285 Secure virtual host HTTP + HTTPS configuration
286 ----------------------------------------------
287
288 This is a secure configuration because:
289
290 - It forces the use of HTTPS for administering Zope in the ZMI.
291
292 - It forces the use of HTTPS for authenticated users (because for
293   logged users cookies containing vulnerable login/password
294   information is sent with each request).
295
296 - It forces the use of HTTPS for users who wish to join the portal
297   (because login information is provided in the join form).
298
299 Example::
300
301   # Main HTTP access to http://www.mysite.net/ for anonymous users
302   <VirtualHost 192.168.2.20:80>
303   ServerName www.mysite.net
304
305   RewriteEngine on
306
307   # Using OR instead of the implicit AND between conditions
308   RewriteCond %{REQUEST_URI} ^(.*)/manage(.*) [OR]
309   RewriteCond %{REQUEST_URI} ^(.*)/login(.*) [OR]
310   RewriteCond %{REQUEST_URI} ^(.*)/account_(.*) [OR]
311   RewriteCond %{REQUEST_URI} ^(.*)/join_form$
312   RewriteRule ^/(.*) https://www.mysite.net/$1 [R=permanent,L]
313
314   RewriteCond %{HTTP:Authorization}  ^(.*)
315   RewriteRule ^/(.*) http://machine.localdomain:9673/VirtualHostBase/http/%{HTTP_HOST}:80/cps/VirtualHostRoot/$1 [P,L]
316
317   CustomLog /var/log/apache2/www.mysite.net.log combined
318   ErrorLog /var/log/apache2/www.mysite.net-error.log
319   </VirtualHost>
320
321   # Main HTTPS access to https://www.mysite.net/ for authenticated users
322   <VirtualHost 192.168.2.20:443>
323   ServerName www.mysite.net
324
325   SSLEngine on
326   SSLCertificateFile /etc/apache2/ssl/apache.pem
327   # Alternatively use those lines for private key and certificate configurations
328   #SSLCertificateFile /etc/apache2/ssl/www.mysite.net.cert
329   #SSLCertificateKeyFile /etc/apache2/ssl/www.mysite.net.key
330
331   RewriteEngine on
332
333   RewriteCond %{HTTP:Authorization}  ^(.*)
334   RewriteRule ^/(.*)  http://machine.localdomain:9673/VirtualHostBase/https/%{HTTP_HOST}:443/cps/VirtualHostRoot/$1 [P,L]
335
336   CustomLog /var/log/apache2/www.mysite.net.log combined
337   ErrorLog /var/log/apache2/www.mysite.net-error.log
338   </VirtualHost>
339
340
341   # HTTPS access to https://www.mysite.net:453/ for administrators.
342   # This is the access to use to administer Zope through the ZMI.
343   <VirtualHost 192.168.2.20:453>
344   ServerName www.mysite.net
345
346   SSLEngine on
347   SSLCertificateFile /etc/apache2/ssl/apache.pem
348   # Alternatively use those lines for private key and certificate configurations
349   #SSLCertificateFile /etc/apache2/ssl/www.mysite.net.cert
350   #SSLCertificateKeyFile /etc/apache2/ssl/www.mysite.net.key
351
352   RewriteEngine on
353
354   RewriteCond %{HTTP:Authorization}  ^(.*)
355   RewriteRule ^/(.*)  http://machine.localdomain:9673/VirtualHostBase/https/%{HTTP_HOST}/VirtualHostRoot/$1 [P,L]
356   # Note that the line below with "%{HTTP_HOST}:453" will not work. The working
357   # rule above has been crafted through the reading of the Z2.log file.
358   #RewriteRule ^/(.*) http://machine.localdomain:9673/VirtualHostBase/https/%{HTTP_HOST}:453/VirtualHostRoot/$1 [P,L]
359
360   CustomLog /var/log/apache2/www.mysite.net.log combined
361   ErrorLog /var/log/apache2/www.mysite.net-error.log
362   </VirtualHost>
363
364
365 Using Apache (apache-ssl package)
366 =================================
367
368 Here are some configuration examples using Apache-SSL VirtualHost
369 directives.
370
371 Note that those configuration instructions are "apache-ssl"
372 specific. It is of course possible to use the "apache" and
373 "libapache-mod-ssl" packages, instead of using the "apache-ssl"
374 package, but the configuration might be slightly different.
375
376 Prerequisites
377 -------------
378
379 What you need:
380
381 1. ::
382
383      $ apt-get install apache-ssl
384
385 2. Be sure to have the following line in your
386    /etc/apache-ssl/modules.conf::
387
388      LoadModule proxy_module /usr/lib/apache/1.3/libproxy.so
389
390 3. You should have the SSLDisable option at the server
391    configuration level because we will be using virtual hosts.
392
393 4. You should generate a private key and certificate files for your
394    web server.
395
396
397 Simple virtual host HTTP + HTTPS configuration
398 ----------------------------------------------
399
400 This configuration is what most people would need. This is not a
401 secure configuration but it is easy to setup and understand.
402
403 Example::
404
405   <VirtualHost 192.168.2.20:80>
406   ServerName www.mysite.net
407
408   RewriteEngine on
409
410   RewriteCond %{HTTP:Authorization}  ^(.*)
411   RewriteRule ^/(.*) http://machine.localdomain:9673/VirtualHostBase/http/%{HTTP_HOST}:80/cps/VirtualHostRoot/$1 [P,L]
412
413   CustomLog /var/log/apache-ssl/www.mysite.net.log combined
414   ErrorLog /var/log/apache-ssl/www.mysite.net-error.log
415   </VirtualHost>
416
417   <VirtualHost 192.168.2.20:443>
418   ServerName www.mysite.net
419
420   SSLEnable
421   SSLCertificateFile /etc/apache-ssl/ssl.crt/apache.pem
422   # Alternatively use those lines for private key and certificate configurations
423   SSLCertificateFile /etc/apache-ssl/ssl.crt/www.mysite.net.cert
424   SSLCertificateKeyFile /etc/apache-ssl/ssl.key/www.mysite.net.key
425
426   RewriteEngine on
427
428   RewriteCond %{HTTP:Authorization}  ^(.*)
429   RewriteRule ^/(.*)  http://machine.localdomain:9673/VirtualHostBase/https/%{HTTP_HOST}:443/cps/VirtualHostRoot/$1 [P,L]
430
431   CustomLog /var/log/apache-ssl/www.mysite.net.log combined
432   ErrorLog /var/log/apache-ssl/www.mysite.net-error.log
433   </VirtualHost>
434
435
436 Secure virtual host HTTP + HTTPS configuration
437 ----------------------------------------------
438
439 This is a secure configuration because:
440
441 - It forces the use of HTTPS for administering Zope in the ZMI.
442
443 - It forces the use of HTTPS for authenticated users (because for
444   logged users cookies containing vulnerable login/password
445   information is sent with each request).
446
447 - It forces the use of HTTPS for users who wish to join the portal
448   (because login information is provided in the join form).
449
450 Example::
451
452   # Main HTTP access to http://www.mysite.net/ for anonymous users
453   <VirtualHost 192.168.2.20:80>
454   ServerName www.mysite.net
455
456   RewriteEngine on
457
458   # Using OR instead of the implicit AND between conditions
459   RewriteCond %{REQUEST_URI} ^(.*)/manage(.*) [OR]
460   RewriteCond %{REQUEST_URI} ^(.*)/login(.*) [OR]
461   RewriteCond %{REQUEST_URI} ^(.*)/account_(.*) [OR]
462   RewriteCond %{REQUEST_URI} ^(.*)/join_form$
463   RewriteRule ^/(.*) https://www.mysite.net/$1 [R=permanent,L]
464
465   RewriteCond %{HTTP:Authorization}  ^(.*)
466   RewriteRule ^/(.*) http://machine.localdomain:9673/VirtualHostBase/http/%{HTTP_HOST}:80/cps/VirtualHostRoot/$1 [P,L]
467
468   CustomLog /var/log/apache-ssl/www.mysite.net.log combined
469   ErrorLog /var/log/apache-ssl/www.mysite.net-error.log
470   </VirtualHost>
471
472   # Main HTTPS access to https://www.mysite.net/ for authenticated users
473   <VirtualHost 192.168.2.20:443>
474   ServerName www.mysite.net
475
476   SSLEnable
477   SSLCertificateFile /etc/apache-ssl/ssl.crt/apache.pem
478   # Alternatively use those lines for private key and certificate configurations
479   SSLCertificateFile /etc/apache-ssl/ssl.crt/www.mysite.net.cert
480   SSLCertificateKeyFile /etc/apache-ssl/ssl.key/www.mysite.net.key
481
482   RewriteEngine on
483
484   RewriteCond %{HTTP:Authorization}  ^(.*)
485   RewriteRule ^/(.*)  http://machine.localdomain:9673/VirtualHostBase/https/%{HTTP_HOST}:443/cps/VirtualHostRoot/$1 [P,L]
486
487   CustomLog /var/log/apache-ssl/www.mysite.net.log combined
488   ErrorLog /var/log/apache-ssl/www.mysite.net-error.log
489   </VirtualHost>
490
491
492   # HTTPS access to https://www.mysite.net:453/ for administrators.
493   # This is the access to use to administer Zope through the ZMI.
494   <VirtualHost 192.168.2.20:453>
495   ServerName www.mysite.net
496
497   SSLEnable
498   SSLCertificateFile /etc/apache-ssl/ssl.crt/www.mysite.net.cert
499   SSLCertificateKeyFile /etc/apache-ssl/ssl.key/www.mysite.net.key
500
501   RewriteEngine on
502
503   RewriteCond %{HTTP:Authorization}  ^(.*)
504   RewriteRule ^/(.*)  http://machine.localdomain:9673/VirtualHostBase/https/%{HTTP_HOST}/VirtualHostRoot/$1 [P,L]
505   # Note that the line below with "%{HTTP_HOST}:453" will not work. The working
506   # rule above has been crafted through the reading of the Z2.log file.
507   #RewriteRule ^/(.*) http://machine.localdomain:9673/VirtualHostBase/https/%{HTTP_HOST}:453/VirtualHostRoot/$1 [P,L]
508
509   CustomLog /var/log/apache-ssl/www.mysite.net.log combined
510   ErrorLog /var/log/apache-ssl/www.mysite.net-error.log
511   </VirtualHost>
512
513
514
515 Hiding "sections" in the URL
516 ============================
517
518 CPS has its contents both in `workspaces` and `sections` folders.
519
520 While being aware of those two locations is fine for users collaborating on a
521 CPS portal (and actually producing contents under the `workspaces` folder), it
522 is disturbing and useless to have ``sections`` in the URL of contents publicly
523 available and accessed by anonymous users.
524
525 A possible solution is to hide the ``sections`` part by adding yet another
526 `RewriteRule` for each public rubric::
527
528   RewriteCond %{REQUEST_URI} ^/rubric-1
529   RewriteRule ^/(.*) http://machine.localdomain:9673/VirtualHostBase/http/%{HTTP_HOST}:80/cps/sections/VirtualHostRoot/$1 [P,L]
530
531   RewriteCond %{REQUEST_URI} ^/rubric-2
532   RewriteRule ^/(.*) http://machine.localdomain:9673/VirtualHostBase/http/%{HTTP_HOST}:80/cps/sections/VirtualHostRoot/$1 [P,L]
533
534   etc.
535
536 Note that those rules should appear before the generic proxying rule defined
537 earlier::
538
539   RewriteRule ^/(.*) http://machine.localdomain:9673/VirtualHostBase/http/%{HTTP_HOST}:80/cps/VirtualHostRoot/$1 [P,L]
540
541 Note that those rules will not hide the true locations of contents as returned
542 by the search pages or the navigation portlets. To this end one usually needs
543 to define custom navigation portlets.
544
545
546
547 Using a web cache
548 =================
549
550 .. _Varnish: http://varnish.projects.linpro.no/
551
552 If a CPS site is heavily loaded by frequent visits it's a good idea to put it
553 behind a web cache.
554
555 The preferred solutions are to use either `Apache httpd`_ or Varnish_.
556
557
558 With Apache httpd
559 -----------------
560
561 From version 2.0 Apache httpd comes with a web cache.
562 But only with Apache httpd version >= 2.2 is this web cache
563 really efficient.
564
565 Add this fragment to your Apache httpd virtual host configuration file::
566
567   <IfModule mod_disk_cache.c>
568     # Enable caching of specified URLs using a specified storage manager
569     CacheEnable disk /
570     # This directory must exist
571     CacheRoot /var/cache/apache2/www.mysite.net
572     # 500Mb of space used on the filesystem
573     CacheSize 512000
574     # Number of characters for each subdirectory name in the cache hierarchy.
575     # This is to try to reduce the number of subdirectories.
576     CacheDirLength 5
577     # Ignore the fact that the client requested the content not be cached
578     CacheIgnoreCacheControl On
579   </IfModule>
580
581
582 With Varnish
583 ------------
584
585 For Varnish_, use version 1.1.1 or up.
586
587 Use the following VCL configuration file::
588
589   backend default {
590           set backend.host = "127.0.0.1";
591           set backend.port = "8080";
592   }
593
594   acl purge {
595           "localhost";
596           "192.0.2.0"/24;
597   }
598
599   sub vcl_recv {
600           if (req.request != "GET" && req.request != "HEAD") {
601                   # PURGE request if zope asks nicely
602                   if (req.request == "PURGE") {
603                           if (!client.ip ~ purge) {
604                                   error 405 "Not allowed.";
605                           }
606                           lookup;
607                   }
608                   pipe;
609           }
610           if (req.http.Expect) {
611                   pipe;
612           }
613           if (req.http.Authenticate || req.http.Authorization) {
614                   pass;
615           }
616           # We only care about the "__ac.*" cookies, used for authentication
617           if (req.http.Cookie && req.http.Cookie ~ "__ac(|_(name|password|persistent))=") {
618                   pass;
619           }
620           lookup;
621   }
622
623   # Do the PURGE thing
624   sub vcl_hit {
625           if (req.request == "PURGE") {
626                   set obj.ttl = 0s;
627                   error 200 "Purged";
628           }
629   }
630   sub vcl_miss {
631           if (req.request == "PURGE") {
632                   error 404 "Not in cache";
633           }
634   }
635
636   # Enforce a minimum TTL, since we PURGE changed objects actively from Zope.
637   sub vcl_fetch {
638           if (obj.ttl < 3600s) {
639                   set obj.ttl = 3600s;
640           }
641   }
642
643
644 Using a load balancer
645 =====================
646
647 .. _CPSApacheProxyBalancer: http://svn.nuxeo.org/trac/pub/browser/CPS3/products/CPSApacheProxyBalancer/trunk
648
649 The specific case of using a load balancer is addressed by the
650 CPSApacheProxyBalancer_ product and documented there.
651
652
653 Developer information
654 =====================
655
656 - Information about how to handle paths/urls in products using
657   CPS, to make them work properly with virtual hosting:
658
659   + http://www.cps-project.org/sections/documentation/developers/virtual_hosting_in_cps
660
661   + http://svn.nuxeo.org/trac/pub/file/CPSCore/trunk/doc/virtual-hosting.txt
662
663
664 .. Local Variables:
665 .. mode: rst
666 .. End:
667 .. vim: set filetype=rst:
Note: See TracBrowser for help on using the browser.