I run several websites on JBoss on my home computer and use Apache as a front-end to redirect requests to the correct sites. Basically if you want your site to be accessible from www.yourdomain.com as is without appending the web app context (e.g., www.yourdomain.com/yourapp) you need to do this. This is also more secure as you can bind JBoss to localhost only and hide the jmx-console.
First of all, you should have defined your web-apps' contexts in their WEB-INF/jboss-web.xml files:
<?xml version="1.0" encoding="UTF-8"?>
<jboss-web>
<context-root>/mywebapp</context-root>
</jboss-web>
Thats all what is needed from JBoss.
Next, you need to add the virtual host configs to Apache httpd.conf file. Example for a single website:
<VirtualHost *:80>
ServerAdmin john@doe.com
ServerName www.mysite.com
ServerAlias mysite.com
ProxyPass / http://localhost:8080/mywebapp/
ProxyPassReverse / http://localhost:8080/mywebapp/
ProxyPreserveHost On
ProxyPassReverseCookiePath / /
ErrorLog logs/mysite-error_log
CustomLog logs/mysite-access_log common
</VirtualHost>
The thing with the proxypass and proxypassreverse directives is that it preserves the domain so you can handle cookies as is on JBoss side without any problems, and that sessions are tracked correctly.
No comments:
Post a Comment