Skip to content. | Skip to navigation

Personal tools
Log in
Sections
You are here: Home How To Plone 3 Virtual Hosting

Virtual Hosting

Update 1/27/09

I have found it now better to use rewrite rules instead of proxying through. An excellent synopsis is found at the plone site. In case that site is down (less likely than this site's being down), here is my configuration:

<VirtualHost 128.125.87.132:80>
    ServerName jamesstroud.com
    ServerAlias www.jamesstroud.com
    DocumentRoot /var/www/htdocs/
    RewriteEngine On
    RewriteRule ^/cv - [L]
    RewriteRule ^/(.*) http://localhost:8080/VirtualHostBase/http/www.jamesstroud.com:80/Plone/VirtualHostRoot/$1 [P,L]
</VirtualHost>

The first RewriteRule opens up a "hole" in my plone site for apache content. For example, try this link: http://www.jamesstroud.com/cv/, for which I made a hole in plone to accommodate the complicated CSS applied to my CV. The second RewriteRule is rewrites URLs to the plone virtual host (the VHM).

Apache2

I like to set up sites such that the plone site takes over the toplevel (i.e. "/") but gets redirected to a subfolder (i.e. "/Home/"). This way, my virtual host is essentially a plone site. But, at the same time, I can have other toplevel directories that can be accessed directly but do not interfere with plone (e.g. "your.site.com/some-utility/"). I also like to run ubuntu when I run Linux, which uses apache2. Setting up virtual hosting according to several different pages resulted in "403 Forbidden. You don't have permission to access /whatever/file on this server." After some experimentation I have found that the minimal virtual hosting configuration for a successful setup with Apache 2 goes a little something like this:

<VirtualHost *>

    DocumentRoot "/var/www/your.site.com"
    ServerName your.site.com
    ServerAlias your.site.com
    ServerAdmin you@site.com

    # override apache2 global defaults
    <Proxy *>
      Order Deny,Allow
      Allow from all
    </Proxy>

    # disallow use of your.site.com as open proxy
    <LocationMatch "^[^/]">
       Deny from all
    </LocationMatch>

    RewriteEngine On

    # Plone in a sub-folder of an apache site
    RedirectMatch ^/$ /Home
    RewriteRule ^/Home(.*) http://localhost:8080/VirtualHostBase/http/your.site.com:80/Plone/VirtualHostRoot/_vh_Home/$1 [P,L]   

</VirtualHost>

In the above case, my VHM is named "VirtualHostMonster" and is configured as described at the plone site.

The above example gets around the server's default to disable proxies, but denies open proxy requests. Some might subbornly attempt to use your apache2 as a proxy, but the resulting proxy will be completely useless. I have stumbled across discussions wherein people claim that explicitly allowing the proxy is not required. However, the discussants never describe an alternative configuration. Also, the above "LocationMatch" directive appears in some long standing web pages as a viable prevention to a potential open proxy.