tomcat多域名配置
今天配置tomcat多域名的时候项目总是加载两次,是因为都用了同样的appBase配置,正确配置如下:
<Engine name="Catalina" defaultHost="localhost">
<Realm className="org.apache.catalina.realm.LockOutRealm">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase"/>
</Realm>
<Host name="a.com" appBase="webapps" unpackWARs="false" autoDeploy="false">
<Alias>aliasdomain.com</Alias>
<Context path="" docBase="/usr/local/tomcat/webapps/ROOT" reloadable="false" caseSensitive="false" debug="0"></Context>
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log" suffix=".txt"
pattern="%h %l %u %t "%r" %s %b"/>
</Host>
<Host name="b.com" appBase="webapps1" unpackWARs="false" autoDeploy="false">
<Context path="" docBase="/usr/local/tomcat/webapps1/ROOT" reloadable="true" caseSensitive="false" debug="0"></Context>
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log" suffix=".txt"
pattern="%h %l %u %t "%r" %s %b"/>
</Host>
</Engine>
appBase要配置成唯一的,否则项目会加载两次。Host>alias可以为此应用绑定多个域名。
<Engine name="Catalina" defaultHost="localhost">
<Realm className="org.apache.catalina.realm.LockOutRealm">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase"/>
</Realm>
<Host name="a.com" appBase="webapps" unpackWARs="false" autoDeploy="false">
<Alias>aliasdomain.com</Alias>
<Context path="" docBase="/usr/local/tomcat/webapps/ROOT" reloadable="false" caseSensitive="false" debug="0"></Context>
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log" suffix=".txt"
pattern="%h %l %u %t "%r" %s %b"/>
</Host>
<Host name="b.com" appBase="webapps1" unpackWARs="false" autoDeploy="false">
<Context path="" docBase="/usr/local/tomcat/webapps1/ROOT" reloadable="true" caseSensitive="false" debug="0"></Context>
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log" suffix=".txt"
pattern="%h %l %u %t "%r" %s %b"/>
</Host>
</Engine>
appBase要配置成唯一的,否则项目会加载两次。Host>alias可以为此应用绑定多个域名。
0
赞
- 所属分类: linux
- 本文标签:
热门推荐
-
2、 - 优质文章
-
3、 gate.io
-
8、 golang
-
9、 openharmony
-
10、 Vue中input框自动聚焦