Home   Up About   Documents   Products   Weblog  

Apache, SSL, 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. If you are wanting to proxy from a HTTPS Apache to a HTTP Glassfish then this article describes how you can do that.

Requirements
  • Apache 2.2.x
  • SSL
  • mod_proxy
  • mod_rewrite
  • Glassfish 1.x+
Setup

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

  ProxyPreserveHost	on
  RewriteEngine		on

  RequestHeader Set Proxy-keysize 512
  RequestHeader Set Proxy-ip %{REMOTE_ADDR}e
  RequestHeader Set Host www.mysecure.com:443

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

The Host request header and the Proxy-keysize request header together make sure response.sendRedirect works properly if you proxy from a HTTPS host to a HTTP application server. The Proxy-ip header gives you access to the original IP-address of the requester.

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.

Add the following attributes to your Glassfish HTTP listener:

  key:		authPassthroughEnabled
  value: 	true

  key:		proxyHandler
  value:	com.sun.enterprise.web.ProxyHandlerImpl

You are now using Apache, SSL, 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.