XWiki Virtual Host Setup Resolved !

I have always been peskered by my lack of knowledge in setting up a virtual host setup in apache that would allow me to hide the name of a webapp in a proxied tomcat server.  After looking for a way to do this right with mod_proxy + mod_rewrite + ext_filter I finally came up with a simple way of doing this that involves not only apache’s site configuration but some tweaking of tomcat’s configuration as well.

What I want, let’s say for Pilango’s XWiki instance is to use URL’s like:

http://xwiki.pilango.com/bin/view/Main/

instead of repeating xwiki in the url as will happen with a default tomcat configuration:

http://xwiki.pilango.com/xwiki/bin/view/Main

I ended up also taking partial advantage of XWiki’s Short URL capabilities by setting

xwiki.showviewaction=0

In XWiki’s xwiki.cfg file and now have URL’s like this:

http://xwiki.pilango.com/bin/Main

Here’s how I did it !

My apache site file:

NameVirtualHost *:80

<VirtualHost *:80>
ServerName xwiki.pilango.com

<Proxy *>
Order deny,allow
Allow from all
</Proxy>

ProxyRequests Off
ProxyPreserveHost On
ProxyPass / http://localhost:8081/
ProxyPassReverse /  http://localhost:8081/
</VirtualHost>

Part of tomcat’s server.xml file that declares a dedicated service for the xwiki instance as the ROOT webapp which is done by the path=”" attribute in the Context element.

  <Service name="xwiki">
    <Connector port="8081" proxyName="xwiki.pilango.com" proxyPort="80" />
    <Engine name="xwiki" defaultHost="localhost">
      <Host name="localhost" appBase="/home/tomcat"
            unpackWars="false" autoDeploy="false"
            xmlValidation="false" xmlNamspaceAware="false">
        <Context docBase="/home/tomcat/xwiki" override="true" path="" />
      </Host>
    </Engine>
  </Service>

Et voilà !

Discussion Area - Leave a Comment