Apache, mod_proxy and Glassfish
Introduction

In general when people think about running a Java based application server with Apache as frontend they almost always think about using mod_jk to proxy to Glassfish, but you can also use mod_proxy quite effectively. This article describes how you can do that.

Requirements Setup

Add the following to make Apache proxy to your Glassfish application:

  ProxyPreserveHost	on
  RewriteEngine		on

  RewriteRule ^/myapp$ /myapp/ [R,L]
  RewriteRule ^/myapp/(.*) http://localhost:8080/myapp/$1 [P,L]
            

Rewrite rule #1 takes care of the trailing slash problem; whereas rewrite rule #2 proxies your requests over to the Glassfish server running at localhost on port 8080. The ProxyPreserveHost directive makes sure that redirects work properly.

Note that this only works for the HTTP protocol. Proxying for an HTTPS host requires a different setup.

You are now using Apache, mod_proxy and Glassfish together. Please send comments, suggestions and any feedback to sales@manorrock.com.

(Glassfish 1)