resin4配置之一个resin下多个app的正确配置做法

作者:袖梨 2026-08-20

可能是因为resin4出来不久的原因,很多人对一个resin配置多个app不是很了解,经过几个小时的研究,有了一些小的成果,在此分享一下:

resin4配置之一个resin下多个app的正确配置方法

在开发的时候很多人习惯了一个resin下配置多个app,习惯了resin3的配置方式,所以resin4出来后就不懂如何配置了。

根据我的理解,配置多个app分为两种情况(此处指一个resin的情况下):

一.同一个域名下多个子app,根据url层级来指向,例如:

http://www.test.com与http://www.test.com/demo/

二.多个域名对应指定的host,根据域名来指向,例如:

http://www.test1.com与http://www.test2.com

第一种的配置方法:

<cluster id="app">

<!-- define the servers in the cluster -->

<server-multi id-prefix="app-" address-list="${app_servers}" port="6801"/>

<host-default>

<!-- creates the webapps directory for .war expansion -->

<web-app-deploy path="webapps"

expand-preserve-fileset="WEB-INF/work/"

multiversion-routing="${webapp_multiversion_routing}"

path-suffix="${elastic_webapp?resin.id:''}"/>

</host-default>

<!-- auto virtual host deployment in hosts/foo.example.com/webapps -->

<host-deploy path="hosts">

<host-default>

<resin:import path="host.xml" optional="true"/>

</host-default>

</host-deploy>

<!-- the default host, matching any host name -->

<host id="" root-directory=".">

<!--

- webapps can be overridden/extended in the resin.xml

-->

<web-app id="/" root-directory="webapps/ROOT"/>

<web-app id="/demo" root-directory="webapps/demo"/>

</host>

</cluster>

第二种的配置方法:

<cluster id="app">

<!-- define the servers in the cluster -->

<server-multi id-prefix="app-" address-list="${app_servers}" port="6801"/>

<host-default>

<!-- creates the webapps directory for .war expansion -->

<web-app-deploy path="webapps"

expand-preserve-fileset="WEB-INF/work/"

multiversion-routing="${webapp_multiversion_routing}"

path-suffix="${elastic_webapp?resin.id:''}"/>

</host-default>

<!-- auto virtual host deployment in hosts/foo.example.com/webapps -->

<host-deploy path="hosts">

<host-default>

<resin:import path="host.xml" optional="true"/>

</host-default>

</host-deploy>

<!--每个host id下也可以包含多个web-app,参考第一种的配置方法-->

<host id="www.test1.com" root-directory=".">

<web-app id="/" root-directory="webapps/test1/ROOT"/>

</host>

<host id="www.test2.com" root-directory=".">

<web-app id="/" root-directory="webapps/test2/ROOT"/>

</host>

</cluster>

相关文章

精彩推荐