转自:https://community.jboss.org/wiki/VirtualHostsWithJBossAS
If you want to set up a virtual host for your web app, create or modify the WEB-INF/jboss-web.xml to contain the highlighted line as follows:
your-app.war/WEB-INF/jboss-web.xml
<jboss-web> <virtual-host>www.mycompany.com</virtual-host> <virtual-host>www.myothercompany.com</virtual-host><context-root>/</context-root> </jboss-web>
The following example shows a vhost configuration for the jmx-console.war for jboss-5.0.
jbossweb.sar/server.xml
<Server> <Service name="jboss.web"> <!-- A HTTP/1.1 Connector on port 8080 --> <Connector protocol="HTTP/1.1" port="8080" address="${jboss.bind.address}" connectionTimeout="20000" redirectPort="8443" ></Connector> <Engine name="jboss.web" defaultHost="localhost"> ... <Host name="localhost"> ... <Valve className="org.jboss.web.tomcat.service.jca.CachedConnectionValve" cachedConnectionManagerObjectName="jboss.jca:service=CachedConnectionManager" transactionManagerObjectName="jboss:service=TransactionManager" ></Valve> </Host> <Host name="loopback"> <Alias>loopback-120</Alias> <Valve className="org.jboss.web.tomcat.service.jca.CachedConnectionValve" cachedConnectionManagerObjectName="jboss.jca:service=CachedConnectionManager" transactionManagerObjectName="jboss:service=TransactionManager" ></Valve> </Host> </Engine> </Service> </Server>
jmx-console.war/WEB-INF/jboss-web.xml
<jboss-web> <!-- Uncomment the security-domain to enable security. You will need to edit the htmladaptor login configuration to setup the login modules used to authentication users. <security-domain>java:/jaas/jmx-console</security-domain> --> <virtual-host>loopback</virtual-host> </jboss-web>
如果提示Failed to map vhost: xxx.domain.com;在/etc/hosts文件中增加127.0.0.1 xxx.dowmain.com行即可。
如果提示WARNING [config] unable to process deployment descriptor for context /xxx;表示你的应用目录里WEB-INF/里面没有web.xml