users@glassfish.java.net

Loadbalancer plugin on Apache with vhosts and no context root

From: <glassfish_at_javadesktop.org>
Date: Tue, 19 Jan 2010 19:38:53 PST

I just got the plugin working with Apache 2.2.13 on Open Solaris (X86)... I have two virtual hosts - one running on port 80 and one on port 443 (not SSL - that's handled at the IP LB). It seems I can get one or the other to work, but not both. One application has no context root, so essentially, I want it to send all requests to the appserver. The other has a context root. Glassfish is running on localhost:9005

If I go to localhost:9005 it forwards me from the app with no context root like it should. If I go to the Apache instance, I get the default index page. localhost:9005/otherapp works and it also works through apache.

I've tried putting the config in the httpd.conf with a single loadbalancer.xml, then the no-context app would work, but not the other with context. So I moved the load module statement into my vhosts.conf file pointing to 2 separate loadbalancer.xml files and now the app with context works, but not the one with no context. Error log says none of the requests are for the LB plugin.

Any ideas?

vhosts file:

NameVirtualHost *:80
NameVirtualHost *:443

<VirtualHost *:80>

    ServerName host.company.com
    DocumentRoot /local/htdocs
    ServerAdmin xxxx_at_xxxx.com
    ErrorLog /local/apache-logs/errors-host.log
    LogLevel debug
    LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
    LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" common
    LogFormat "%{Referer}i -> %U" referer
    LogFormat "%{User-agent}i" agent
    CustomLog /local/apache-logs/access-host.log combined
LoadModule apachelbplugin_module modules/mod_loadbalancer.so

<IfModule apachelbplugin_module>
                config-file "/programs/apache-2.2.13/conf/loadbalancer.xml"
                locale en
</IfModule>

</VirtualHost>

<VirtualHost *:443>

    ServerName admin.company.com
    ServerAdmin xxx_at_xxxx.com
    DocumentRoot /local/htdocs
    ErrorLog /local/apache-logs/errors-admin.log
    LogLevel debug
    LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
    LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" common
    LogFormat "%{Referer}i -> %U" referer
    LogFormat "%{User-agent}i" agent
    CustomLog /local/apache-logs/access-admin.log combined

<IfModule apachelbplugin_module>
                config-file "/programs/apache-2.2.13/conf/loadbalancer2.xml"
                locale en
</IfModule>

</VirtualHost>

Clearly it is reading the 2nd loadbalancer2.xml because it works.

loadbalancer.xml

<loadbalancer>
   <cluster name="vf1" policy="round-robin">
       <instance name="vf1" enabled="true" disable-timeout-in-minutes="60" listeners="http://localhost:9005" weight="100"/>
        <web-module context-root="/" enabled="true" disable-timeout-in-minutes="60" error-url="http://www.company.com/maintenance.html" />
        <health-checker url="/" interval-in-seconds="10" timeout-in-seconds="30" />
    </cluster>
    <property name="reload-poll-interval-in-seconds" value="60"/>
    <property name="response-timeout-in-seconds" value="30"/>
    <property name="https-routing" value="true"/>
    <property name="require-monitor-data" value="false"/>
    <property name="active-healthcheck-enabled" value="false"/>
    <property name="number-healthcheck-retries" value="3"/>
    <property name="rewrite-location" value="true"/>
</loadbalancer>

loadbalancer2.xml

<!DOCTYPE loadbalancer PUBLIC "-//Sun Microsystems Inc.//DTD Sun ONE Application Server 7.1//EN" "sun-loadbalancer_1_2.dtd">
<loadbalancer>
    <cluster name="vf1" policy="round-robin">
        <instance name="vf1" enabled="true" disable-timeout-in-minutes="60" listeners="http://localhost:9005" weight="100"/>
        <web-module context-root="/vfadmin" enabled="true" disable-timeout-in-minutes="60" error-url="http://www.company.com/maintenance.html" />
        <health-checker url="/" interval-in-seconds="10" timeout-in-seconds="30" />
    </cluster>
    <property name="reload-poll-interval-in-seconds" value="60"/>
    <property name="response-timeout-in-seconds" value="30"/>
    <property name="https-routing" value="true"/>
    <property name="require-monitor-data" value="false"/>
    <property name="active-healthcheck-enabled" value="false"/>
    <property name="number-healthcheck-retries" value="3"/>
    <property name="rewrite-location" value="true"/>
</loadbalancer>
[Message sent by forum member 'misschatter' (misschatter_at_gmail.com)]

http://forums.java.net/jive/thread.jspa?messageID=381868