In general when people think about running a Java based application server with Apache as front-end 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+
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 sales@manorrock.com.
(Glassfish 1)