[Nolug] Troubles with Virtual Hosts in Tomcat in Ubuntu 14.04

From: Gilberto Martins <gsilva.martins_at_gmail.com>
Date: Fri, 8 Aug 2014 16:45:05 -0300
Message-ID: <CAHBhT5_mxW+F92B1Q421HoVU2xo5QMXCtfSod3mwLSU0q6QQfA@mail.gmail.com>

Hi.

I am having bad moments in configuring a Virtual host in this server. Let
me first introduce you to this scenario:
- Ubuntu 14.04.1 LTS
- Tomcat 7.0.52-1ubuntu0.1
- Java 1.7.0_60

Hostname is correctly configured:
$ hostname
apprd01.mydomain.com
$ hostname -i
10.1.3.99

The directory where I save the virtual host definitions is
"/var/lib/tomcat7/VirtualHosts". In this directory (for now) there will be
directories for each virtual host:

$ ls -ld /var/lib/tomcat7/VirtualHosts/WebApps00*
drwxrwx--- 3 tomcat7 tomcat7 4096 Aug 1 11:15
/var/lib/tomcat7/VirtualHosts/WebApps001
drwxrwx--- 3 tomcat7 tomcat7 4096 Aug 1 13:24
/var/lib/tomcat7/VirtualHosts/WebApps002
drwxrwx--- 3 tomcat7 tomcat7 4096 Aug 1 11:15
/var/lib/tomcat7/VirtualHosts/WebApps003

Consider that "mydomain.com" is replacing the real domain name. In
/etc/tomcat7/server.xml, I define each of the 3 virtual hosts in Engine
"Catalina", as follows (comments removed):

    <Engine name="Catalina" defaultHost="localhost">
      <Host name="localhost" appBase="webapps"
            unpackWARs="true" autoDeploy="true">
        <Valve className="org.apache.catalina.valves.AccessLogValve"
       directory="logs"
               prefix="localhost_access_log." suffix=".txt"
               pattern="%h %l %u %t &quot;%r&quot; %s %b" />

      </Host>
        <Host name="fiscalizacao.mydomain.com"
                unpackWARs="true"
                autoDeploy="true"
                appBase="VirtualHosts/WebApps001">
                <Valve className="org.apache.catalina.valves.AccessLogValve"
                        prefix="fiscalizacao_access_log."
                        suffix=".txt"
                        pattern="common"/>
        </Host>

        <Host name="efiscalizacao.mydomain.com"
                unpackWARs="true"
                autoDeploy="true"
                appBase="VirtualHosts/WebApps002">
                <Valve className="org.apache.catalina.valves.AccessLogValve"
                        prefix="efiscalizacao_access_log."
                        suffix=".txt"
                        pattern="common"/>
        </Host>

        <Host name="registrocontrato.mydomain.com"
                unpackWARs="true"
                autoDeploy="true"
                appBase="VirtualHosts/WebApps003">
                <Valve className="org.apache.catalina.valves.AccessLogValve"
                        prefix="registrocontrato_access_log."
                        suffix=".txt"
                        pattern="common"/>
        </Host>
    </Engine>

The names "fiscalizacao.mydomain.com", "efiscalizacao.mydomain.com" and "
registrocontrato.mydomain.com" are already announced in DNS.

When Tomcat is started, I get this messages in
/var/log/tomcat7/catalina.out:
[...]
Aug 04, 2014 10:08:22 AM org.apache.catalina.startup.HostConfig
deployDirectory
INFO: Deploying web application directory
/var/lib/tomcat7/VirtualHosts/WebApps001/ROOT
Aug 04, 2014 10:08:24 AM org.apache.catalina.startup.HostConfig
deployDirectory
INFO: Deploying web application directory
/var/lib/tomcat7/VirtualHosts/WebApps002/ROOT
Aug 04, 2014 10:08:26 AM org.apache.catalina.startup.HostConfig
deployDirectory
INFO: Deploying web application directory
/var/lib/tomcat7/VirtualHosts/WebApps003/ROOT
[...]

That means, no error in starting them.

Unfortunately, when I access any of the pages I receive a 404 page. Their
logs show the following:
$ sudo cat /var/log/tomcat7/registrocontrato_access_log.2014-08-04.txt
187.40.1.64 - - [04/Aug/2014:09:38:54 -0300] "GET /registrocontrato
HTTP/1.1" 404 1001
187.40.1.64 - - [04/Aug/2014:09:38:54 -0300] "GET /favicon.ico HTTP/1.1"
404 991

What I am not doing, or doing wrongly?
If any other information is needed, please ask.

Gilberto Martins

___________________
Nolug mailing list
nolug@nolug.org
Received on 08/08/14

This archive was generated by hypermail 2.2.0 : 08/15/14 CDT