To integrate JBoss behind an Apache server you often use the mod_jk
module. There is another solution which combines the use of Apache mod_rewrite and [
Apache and JBoss integration with mod_rewrite and mod_proxy
By Stephane Carrez2009-01-28 21:21:29 1 comments
The problem I wanted to solve was to be able to use the Apache URL rewrite before forwarding the request to a JBoss server. The Apache and JBoss were already integrated with mod_jk (Deploying a J2EE application behind an Apache server). The URL rewriting rule does not work in that case (at least I was not able to make it work). I investigated the Apache mod_rewrite and its proxy configuration.
First, in your Apache host configuration you have to enable the Apache rewrite module. This is done by the RewriteEngine directive. To make sure that the server name is propagated to JBoss, you have to use the ProxyPreserveHost directive. If you don't do this, JBoss will receive 'localhost' as server name (ie, the servlet request getServerName()
method will not return what you expect). You then define your rewrite rule and use the proxy forwarding mode indicated by [P].
<VirtualHost *:80>
RewriteEngine On
ProxyPreserveHost On
RewriteRule ^/some-path/(.*)$ \
http://localhost:8080/web-app-deploy-name/$1 \[P\]
...
</VirtualHost>
You have to make sure the Apache modules are available, for this execute these commands:
sudo a2enmod proxy proxy_http rewrite
Once your configuration files are ready, reload Apache configuration:
sudo /etc/init.d/apache2 reload
That it!
This mod_rewrite and mod_proxy configuration is very powerful and easier to setup than mod_jk.
Tags
- Facelet
- NetBSD
- framework
- Mysql
- generator
- files
- application
- gcc
- ReadyNAS
- Security
- binutils
- ELF
- JSF
- Java
- bacula
- Tutorial
- Apache
- COFF
- collaboration
- planning
- project
- upgrade
- AWA
- C
- EL
- J2EE
- UML
- php
- symfony
- Ethernet
- Ada
- FreeBSD
- Go
- KVM
- MDE
- Proxy
- STM32
- Servlet
- backup
- lvm
- multiprocessing
- web
- Bean
- Jenkins
- release
- OAuth
- ProjectBar
- REST
- Rewrite
- Sqlite
- Storage
- USB
- Ubuntu
- bison
- cache
- crash
- Linux
- firefox
- performance
- interview
Add a comment
To add a comment, you must be connected. Login1 comments
Good tip. Would suggest you change the Rewrite to include the trailing / in the RegEx parameter... then this URL will also work:
http://yourserver/some-path
and run the default page from JBoss.
RewriteRule ^/some-path(.*)$ \
http://localhost:8080/web-app-deplo... [P]