For this example we'll have two subdomains, let's say domainA.net2tel.com.br and domainB.net2tel.com.br, both pointing to the same Apache server (same IP actually)). Two applications run on an internal JBoss server, for instance http://jboss:8080/appA and http://jboss:8080/appB
Environment
All this serie's posts refer to the following environment: Mobicents 1.5.0 (based on JBoss 5.1.0.GA) / Java 6 / Apache 2.2.3 (mod_proxy_html 2.5) on Linux Debian.
Configuration
The configuration to put JBoss behind Apache is actually quite simple. Simple but every single detail counts.
We use mod_proxy_ajp, available since Apache 2.2. One other possible solution was mod_jk but the setup seemed consideralby more complex, without clear advantage of this module.
The configuration is documented below. Directives ProxyPassReverseCookiePath and RewriteRule will be explained later, they are a solution to form-based authentication problems. ProxyHTMLURLMap is a solution to another issue, wich will be explained later too.
It is entirely contained in the httpd.conf (but could be put in a different file, depending ou the setup)
# This directive is needed in order to use named virtual hosts
# specify the IP/port on which the server will receive
# requests for the name-based virtual hosts
# Note that the specified address should match exactly the one
# specified as VirtualHost name
NameVirtualHost *:80
# Prevents Apache from functioning as a forward proxy server
# In a typical reverse proxy, set to off (which is the default value)
ProxyRequests Off
<VirtualHost *:80>
# Define the domain name served by this virtual host
ServerName domainA.net2telcom.br
# Proxy requests to the java application
ProxyPass / ajp://jboss:8009/appA/
# Revrites http headers (Location, Content-Location, URI)
# on http redirect responses to avoid bypassing this gateway
# in redirects coming from the web application
ProxyPassReverse / ajp://jboss:8009/appA/
# Adjusts the Path string in Set-Cookie headers
ProxyPassReverseCookiePath /appA /
# Filters output HTML to convert the context path
# generated from the proxyied server to the one
# on this proxy
SetOutputFilter proxy-html
ProxyHTMLURLMap /appA/ /
# Redirects requests to the /portability URL to
# the root. It is needed for java form-based authentication
# on JBoss (which redirects to the context path after login)
RewriteEngine On
RewriteRule ^/appA/(.*)$ /$1 [R]
</VirtualHost>
<VirtualHost *:80>
ServerName domainB.net2tel.com.br
ProxyPass / ajp://jboss:8009/appB/
ProxyPassReverse / ajp://jboss:8009/appB/
[Rest of the config omitted]
</VirtualHost>
<Proxy ajp://jboss:8009>
Order allow,deny
Allow from all
</Proxy>
Next Step : "JSF, RichFaces and mod_proxy_html"

0 comments:
Post a Comment