Apache + JBoss

From Oxxus Wiki

Jump to: navigation, search

Apache web server, with proxy_ajp module, is installed by default within every VPS hosting plan we offer. It's required because JBoss is set, again by default, to port 8080 and all incoming requests from standard web port 80 which are related to java contents, are forwarded to JBoss server, port 8080, by this module.

Configurations regarding this module are quite simple and maps all requests from port 80 to 8080. Exclusion can be defined as well but only to entire folder and it's sub-folders. Mapping per file extension, for example if you need to have PHP and Java contents server from same folder, is not available by this module. If this is what you require, we offer mod_jk, another Apache module, which has this feature enabled. Although mod_jk requires more configuration, it provides, on the other hand, more sophisticated configuration options.

Here are examples for modules mentioned above.

proxy_ajp configuration example

Only one configuration file is required to have this module active and redirect java requests to Jboss , named java.conf, at our VPS accounts, with contents as shown below. File is placed at Apache's configuration folder so apache can pick it up upon start-up.

ProxyPass /webmail !
ProxyPass /phpMyAdmin !
ProxyPass /phpPgAdmin !
ProxyPass /cgi-bin !
ProxyPass /server-status !

ProxyPass / http://127.0.0.1:8080/
ProxyPassReverse / http://127.0.0.1:8080/
ProxyPreserveHost on

We've predefined some exclusions, as shown above, which lets Apache to handle contents.

mod_jk configuration example

Several configuration files are required for this module to work, however the module provides far more detailed configuration features than proxy_ajp. Main and most used is ability to define redirection to JBoss service per file extensions, as shown below in our example.

Like proxy_ajp, all configuration files have to be placed within Apache's configuration folder so they can be picked up once Apache start.

First file is named mod_jk.conf:

LoadModule    jk_module  modules/mod_jk.so
JkWorkersFile /etc/httpd/conf/workers.properties
JkLogFile     /var/log/httpd/mod_jk.log
JkLogLevel    info
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "

It invokes file workers.properties:

worker.ajp13.port=8009
worker.ajp13.host=localhost
worker.ajp13.type=ajp13

Now, mod_jk is enabled but definition of what is to be mounted is also required. This can be done from one of previous files or within Apache configuration file.

JkMount /* ajp13
JkMount /servlet/* ajp13

JkUnMount /*.php  ajp13
JkUnMount /*/*.php  ajp13
JkUnMount /*/.shtml  ajp13
JkUnMount /.shtml  ajp13
JkUnMount /admin/*  ajp13
JkUnMount /webmail/*  ajp13

As defined above, everything is mounted to java services, JBoss in this case, and then certain files extensions, like PHP, are left unmounted. Entire folders can be mounted or unmounted as well. With this configuration, your web site will be able to serve Apache/PHP and java contents at the same time from same folder, for entire web site.

Contact About Us Support Network Servers Java Hosting Oxxus.net Order Now! Dedicated Servers VPS Hosting Tomcat Hosting Java Hosting Money Back Guarantee Privacy Policy Oxxus.net Terms of 
Service Contact About Us Servers Networks Support Domain Names SSL Certificates Java Wiki Tutorials E-learning 
Platforms