1

I'm having a problem with getting additional virtual hosts to proxy correctly with Apache/Tomcat. Basically, I have a primary virtual site that is Proxy'd to Tomcat and that works fine. However, the additional virtual hosts that I setup don't work. They all reverse back to the primary site. This is the first time I've set this up so I'm obviously doing something [probably simple] that is causing the problem.

    <VirtualHost *:80>
       ServerAdmin webmaster@secondary_domain.com
       ServerName secondary_domain.com
       ServerAlias www.secondary_domain.com
       ProxyPreserveHost       On
       ProxyPass               /       ajp://localhost:8009/
       ProxyPassReverse        /       ajp://localhost:8009/

       DocumentRoot /var/www/secondary_domain.com
       DirectoryIndex index.jsp

       <Directory />
            Options FollowSymLinks
            AllowOverride None
    </Directory>
    <Directory /var/www/secondary_domain.com/>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride All
            Order allow,deny
            allow from all
    </Directory>

    ErrorLog /var/www/secondary_domain.com/logs/error.log

    LogLevel warn

    CustomLog /var/www/secondary_domain.com/logs/access.log combined

    <IfModule mpm_itk_module>
            AssignUserId user userg
    </IfModule>

and here's the tomcat server.xml file

<!-- Define an AJP 1.3 Connector on port 8009 -->
<Connector port="8009"
           enableLookups="false" redirectPort="8443" protocol="AJP/1.3" />

<!-- Define a Proxied HTTP/1.1 Connector on port 8082 -->
<!-- See proxy documentation for more information about using this. -->
<!--
<Connector port="8082"
           maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
           enableLookups="false" acceptCount="100" connectionTimeout="20000"
           proxyPort="80" disableUploadTimeout="true" />
-->

<!-- An Engine represents the entry point (within Catalina) that processes
     every request.  The Engine implementation for Tomcat stand alone
     analyzes the HTTP headers included with the request, and passes them
     on to the appropriate Host (virtual host). -->

<!-- You should set jvmRoute to support load-balancing via AJP ie :
<Engine name="Standalone" defaultHost="localhost" jvmRoute="jvm1">
-->

<!-- Define the top level container in our container hierarchy -->
<Engine name="Catalina" defaultHost="localhost">
    <Host name="primary_domain.com"               appBase="/var/www/primary_domain.com"/>
    <Host name="secondary_domain.com"          appBase="/var/www/secondary_domain.com">
            <alias>www.secondary_domain.com</alias>
    </Host>
SARGuy
  • 11
  • 2

1 Answers1

0

It's hard to guess based on just the config of one vhost, but a couple of likely causes:

  • Make sure your <VirtualHost> specifications match your NameVirtualHost directive.

    For example, you probably have NameVirtualHost *:80, so your new vhosts need to be set up as <VirtualHost *:80>, with appropriate ServerName/ServerAlias configs to get the requests to them.

  • To make sure Tomcat has the info it needs to send to the different appBase for the different host names, you'll need to make sure that ProxyPreserveHost is enabled for all of your sites.

Shane Madden
  • 112,982
  • 12
  • 174
  • 248
  • Thanks Shane but all of those suggestions are already in place. All of the Virtual Hosts are identical in terms of configs, the only change is the path. ProxyPreserveHost is on but I'm not confident the host is being passed to Tomcat since the primary web page comes up for any of the domains on the Tomcat server – SARGuy Oct 03 '11 at 18:39
  • @SARGuy Then, please provide more of your configuration details, especially the working virtualhost - it's hard to get an idea of what the problem is without a full picture of the configuration. – Shane Madden Oct 03 '11 at 18:42