Tomcat -Virtual hosts and Access logging

In CategoryComputer Networks, Linux
Bysreekanth

Some times we may need to run multiple websites on single ip address with the same port number ,for example http( tcp-80 ) port .

If I have 2 websites called  www.example1.com and  www.example2.com pointing to same webserver 10.0.0.10,  then i will configure my tomcat webserver( 10.0.0.10 )following way .

 

Using vim editor i will  edit /tomcat_directory/conf/server.xml and add seperate  virtual host entries for each domain .

 

<Host name=”www.example1.com” debug=”0″ appBase=”example1″
unpackWARs=”true” autoDeploy=”true”
xmlValidation=”false” xmlNamespaceAware=”false”>
<Context path=”” docBase=”.”/>
<Logger className=”org.apache.catalina.logger.FileLogger”
directory=”logs” prefix=”localhost_log.” suffix=”.txt”
timestamp=”true”/>
<Valve className=”org.apache.catalina.valves.AccessLogValve” directory=”logs”

prefix=”localhost_access_log.” suffix=”.txt” pattern=”common” resolveHosts=”false”/>

<Host name=”www.example2.com” debug=”0″ appBase=”example2″
unpackWARs=”true” autoDeploy=”true”
xmlValidation=”false” xmlNamespaceAware=”false”>
<Context path=”” docBase=”.”/>
<Logger className=”org.apache.catalina.logger.FileLogger”
directory=”logs” prefix=”localhost_log.” suffix=”.txt”
timestamp=”true”/>
<Valve className=”org.apache.catalina.valves.AccessLogValve” directory=”logs”

prefix=”localhost_access_log.” suffix=”.txt” pattern=”common” resolveHosts=”false”/>

</Host>

</Engine>

</Service>

</Server>

 

 

example1 and example2  are root directories  where we  can copy webpages .

<Valve className=”org.apache.catalina.valves.AccessLogValve” directory=”logs”

prefix=”localhost_access_log.” suffix=”.txt” pattern=”common” resolveHosts=”false”/>  ……. this entry will log  website access logs  in /tomcat_directory/logs .

 

 

Leave a Reply