GlassFish Configuration

  • Create a mod_ajp enabled network listener
asadmin create-network-listener --listenerport 8009 --protocol http-listener-1 --jkenabled true jk-connector
  • Restart GlassFish

Note : the above works with 3.1.2.  The trunk needs a jk-enabled http instead of network-listener. This will be supported in the future Grizzly version.

<protocol name="jk-connector">
    <http default-virtual-server="server" jk-enabled="true">
    </http>
</protocol>

<network-listener port="8009" protocol="jk-connector" transport="tcp" name="jk-connector" thread-pool="http-thread-pool"></network-listener>

Apache Configuration

  • Install apache httpd server & mod_proxy_ajp (mod_proxy_ajp is built as part of apache httpd)
  • Edit httpd.conf to contain
LoadModule proxy_ajp_module modules/mod_proxy_ajp.so

Include conf/other/*.conf
  • Open confg/other/ajp.config and paste the following
ProxyRequests Off

        Order deny,allow
        Deny from all
        Allow from localhost

ProxyPass               / ajp://localhost:8009/
ProxyPassReverse        / ajp://localhost:8009/
  • Start Apache

Now any http://localhost:80 request will direct to GlassFish

If you need only redirect certain webapp (ex. hello), you can modify ajp.config

ProxyRequests Off

        Order deny,allow
        Deny from all
        Allow from localhost

ProxyPass               /hello ajp://localhost:8009/hello
ProxyPassReverse        /hello ajp://localhost:8009/hello
Now only http://localhost:80/hello request will direct to GlassFish hello application.