Two DNS Names for two Web apps in jboss 7.1.1

2019-03-05 05:21发布

问题:

I have a problem. I have two web apps deployed as wars. Let's call them app1.war and app2.war.

I would like app1.war to be accessed at the URL www.website.com and I would like app2.war to be accessible as www.anotherweb.com. I have my domain name ready.

I am able to run the application as www.website.com/app1, www.website.com/app2.

So Now i need to run using www.website.com and www.anotherweb.com

I am running JBoss7.1.1.

Thanks for any insights.

回答1:

You need to put Apache Http server between user and JBoss server and not access your server directly from web. Configure Apache HTTP server to use mod_proxy with virtual host configuration. If your JBoss server runs on http://localhost:8080, it will look something like this in httpd.conf.

NameVirtualHost *:80

<VirtualHost *:80>
    RewriteEngine On
    ServerName www.website.com
    ProxyPass / http://localhost:8080/app1/
    ProxyPassReverse / http://localhost:8080/app1/
</VirtualHost>

<VirtualHost *:80>
    RewriteEngine On
    ServerName www.anotherweb.com
    ProxyPass / http://localhost:8080/app2/
    ProxyPassReverse / http://localhost:8080/app2/
</VirtualHost>