Home   Up About   Documents   Products   Weblog  

Apache, mod_proxy and Glassfish v1+
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
  • Apache 2.2.x
  • mod_proxy
  • mod_rewrite
  • Glassfish 1.x
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 now are using Apache, mod_proxy and Glassfish together. Please send comments, suggestions and any feedback to mriem@manorrock.org.

(Glassfish 9.0+)


Copyright © 2003-2008, Manfred Riem. All Rights Reserved.