我加入了另一臺主機vhost2
到server.xml
文件夾裏面${jboss-home}server\default\deploy\jbossweb-tomcat55.sar
文件夾如下:
<Server>
<Service name="jboss.web"
className="org.jboss.web.tomcat.tc5.StandardService">
<Connector port="8080" address="${jboss.bind.address}"
maxThreads="250" strategy="ms" maxHttpHeaderSize="8192"
emptySessionPath="true"
enableLookups="false" redirectPort="443" acceptCount="100"
connectionTimeout="20000" disableUploadTimeout="true"/>
<Connector protocol="HTTP/1.1" port="8081" address="${jboss.bind.address}"
redirectPort="${jboss.web.https.port}" />
<Connector port="8089" address="${jboss.bind.address}"
emptySessionPath="true" enableLookups="false" redirectPort="443"
protocol="AJP/1.3"/>
<Connector port="8445" address="${jboss.bind.address}"
maxThreads="100" strategy="ms" maxHttpHeaderSize="8192"
emptySessionPath="true"
scheme="https" secure="true" clientAuth="false"
keystoreFile="${jboss.server.home.dir}/conf/bookstore.keystore"
keystorePass="bookstore" sslProtocol = "TLS" allowTrace="true"/>
<Engine name="jboss.web" defaultHost="localhost">
<Realm className="org.jboss.web.tomcat.security.JBossSecurityMgrRealm"
certificatePrincipal="org.jboss.security.auth.certs.SubjectDNMapping"
/>
<Host name="localhost"
autoDeploy="false" deployOnStartup="false" deployXML="false">
</Host>
<Host name="vhost2" autoDeploy="false"
deployOnStartup="false" deployXML="false">
<Alias>testsite1</Alias>
<Valve className="org.apache.catalina.valves.AccessLogValve"
prefix="vhost2" suffix=".log" pattern="common"
directory="${jboss.server.home.dir}/log"/>
<DefaultContext cookies="true" crossContext="true" override="true"/>
</Host>
</Engine>
</Service>
</Server>
然後我添加了一個新的文件jboss-web.xml
在STORE-DEF.war
WEB-INF
文件夾內,如下所示:
<jboss-web>
<context-root>/</context-root>
<virtual-host>testsite1</virtual-host>
</jboss-web>
現在我我能夠從URL http://localhost:8080/home
和STORE-DEF.war
從URL http://testsite1:8080/home
訪問STORE-ABC.war
。
注意 - 不要忘了在hosts
文件中添加127.0.0.1 testsite1
。