Virtual Host Configuration in JBoss
Virtual Host Configuration in JBoss 6.1.0 EAP / Jboss7 COMMUNITY EDITION
"Virtual Hosts" is a method to serve requests for multiple host names for example you access your website similar to real host names like http://trvajjala.in
If you want set virtual host to your application you need to follow below instructions.
Configure Virtual Hosts in standalone.xml
Open standalone.xml under ${JBOSS}/standalone/configuration folder and configure below virtual hosts configurations in one of subsystems.
If you have multiple applications in the same server you can use separate virtual host entry.
<subsystem xmlns="urn:jboss:domain:web:1.4" default-virtual-server="default-host" native="false">
<connector name="http" protocol="HTTP/1.1" scheme="http" socket-binding="http"/>
<connector name="ajp" protocol="AJP/1.3" scheme="ajp" socket-binding="ajp" enabled="true"/>
<virtual-server name="default-host" enable-welcome-root="true">
<alias name="localhost"/>
<alias name="example.com"/>
</virtual-server>
<virtual-server name="VirtualServer-One" default-web-module="webModuleOne">
<alias name="localhost"/>
<alias name="one.trvajjala.com"/>
</virtual-server>
<virtual-server name="VirtualServer-Two" default-web-module="webModuleTwo">
<alias name="localhost"/>
<alias name="two.trvajjala.com"/>
</virtual-server>
</subsystem>
|
Change the http port to 80 from 8080 so that you need not required specifying port as well.
This needs to change under socket-binding-group section.
<socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:0}">
<socket-binding name="http" port="80"/>
</socket-binding-group>
|
If this you want to make it available in LAN change mention IP address under interfaces section.
<interfaces>
<interface name="management">
<inet-address value="${jboss.bind.address.management:127.0.0.1}"/>
</interface>
<interface name="public">
<inet-address value="${jboss.bind.address:192.168.0.1}"/>
</interface>
<interface name="unsecure">
<inet-address value="${jboss.bind.address.unsecure:127.0.0.1}"/>
</interface>
</interfaces>
|
Specify the same in jboss-web.xml specific to application
Next step is to create jboss-web.xml under WEB-INF folder of your web module.
And mention below content. <context-root> must be / and <virtual-host> value should match with standalone.xml virtual-server name which we mentioned in the first section.
<jboss-web>
<context-root>/ </context-root>
<virtual-host>VirtualServer-One</virtual-host>
</jboss-web>
|
MENTION same thing in the host file.
Open your host files and add entry as shown below.
# IP-ADDRESS ALIAS-NAME
192.168.0.1 one.trvajjala.in
192.168.0.1 two.trvajjala.in
Now you can access your application using http://one.trvajjala.in which will render content from http://192.168.0.1:8080/webModuleOne
Comments
Post a Comment