Date: Fri, 29 Mar 2024 14:31:01 +0000 (UTC) Message-ID: <1232457351.6651.1711722661388@cwiki-he-fi.apache.org> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_6650_1396457777.1711722661388" ------=_Part_6650_1396457777.1711722661388 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html
This instruction will help you configuring Cocoon along with Tom= cat for virtual hosting. We are going to serve several virtual hosts each f= rom its own directory.
=20 Host Directory http://customerA/ /opt/virtHosts/customerA/ http://customerB/ /opt/virtHosts/customerB/ http://customerC/ /opt/virtHosts/customerC/ http://www.foo.tld/ /opt/virtHosts/www.foo.tld/
You have installed and configured Cocoon and Tomcat according to CocoonEasyInstallati= on.
/opt/jakarta-tomcat-5.x.xx /opt/cocoon/
Now create the following directories
/opt/virtHosts/customerA/ /opt/virtHosts/customerB/ /opt/virtHosts/customerC/ /opt/virtHosts/www.foo.tld/
Make sure your Nameserver knows about all the hosts. If you are on a loc=
al machine without nameserver you can add them to /etc/hosts file.
Put some sample which you know that is working into each customerX directo=
ry.
The default sitemap already has many =
Matchers defined but there are some more that we could add.
Backup your /opt/cocoon/ROOT/sitemap.xmap and open it wit=
h your favourite editor. Search for the section
<map:components> ...other components... <map:matchers default=3D"wildcard"> ...other matchers... </map:matchers> ...other components... </map:components>
and add the line
<map:matcher logger=3D"sitemap.matcher.host" name=3D"host" src= =3D"org.apache.cocoon.matching.WildcardHostMatcher"/>
so that you now have
<map:components> ...other components... <map:matchers default=3D"wildcard"> ...other matchers... <map:matcher logger=3D"sitemap.matcher.host" name=3D"host" src=3D"o= rg.apache.cocoon.matching.WildcardHostMatcher"/> ...other matchers... </map:matchers> ...other components... </map:components>
Now as our sitemap.xmap knows about WildcardHostMatcher we can use it in our= pipeline.
Search for the section <map:pipelines> and find the <map:pipeli= ne> which is commented "main pipeline".
<map:pipelines> ...others... <!-- main pipeline --> <map:pipeline>
and directly below, and still above the welcome pages, add the lines:
<!-- Insertion for matching http://cocoon:[portnumber]/ --> <map:match pattern=3D"cocoon:**" type=3D"host">
Further down in the pipeline, just before beginning of comment about err= or handling <map:handle-errors> put the folllowing lines of which the= first is the closing tag of our previous insertion from above.
</map:match> <!--+ | Mount everything else by calling the sitemap.xmap file located | in the requested folder. | First match, pattern=3D"*:**" is for http://virthost:8080/uri | Second one, pattern=3D"*" is for calling at default port. +--> <map:match pattern=3D"*:**" type=3D"host"> <map:mount check-reload=3D"yes" src=3D"/opt/virtHosts/{1}/" uri-pr= efix=3D""/> </map:match> <map:match pattern=3D"*" type=3D"host"> <map:mount check-reload=3D"yes" src=3D"/opt/virtHosts/{1}/" uri-pr= efix=3D""/> </map:match>
Save your changes to sitemap.xmap.
Be aware that we added one new matcher matching *http://cocoon:\[portnum=
ber\]/* nested with all other matches from the original pipeline.
Please change it from pattern=3D"cocoon:**" to pa=
ttern=3D"cocoon" if you've connected Tomcat to Apache or if you co=
nfigured Tomcat to listen on port 80. Restart Tomcat and start your browser=
with *http://customerA/* or another.
Setting up a new virtual host requires just only creating in /opt/virtHo= sts/ a directory with its name being the same as the host name.
Feel free to put any comments or corrections or to contact the author fo= r questions under volkmar@pogatzki.net
Of course, Cocoon has a RegexpHostMatcher too and also a HostSelector which already got = its own wikipage HostSe= lector.
If you prefer having Apache in front to match the (virtual) hosts, pleas= e have a look at Stavros Kounis' VirtualHost.