1,在D盘跟目录建个tomcat_server目录,结构如下
:
其中tomcat1的server.xml为
<?xml version='1.0' encoding='utf-8'?>
<Server port="8005" shutdown="SHUTDOWN">
<Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
<Listener className="org.apache.catalina.core.JasperListener" />
<Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
<Listener className="org.apache.catalina.mbeans.ServerLifecycleListener" />
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
<GlobalNamingResources>
<Resource name="UserDatabase" auth="Container"
type="org.apache.catalina.UserDatabase"
description="User database that can be updated and saved"
factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
pathname="conf/tomcat-users.xml" />
</GlobalNamingResources>
<Service name="Catalina">
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
<Engine name="Catalina" defaultHost="localhost">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase"/>
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
</Host>
</Engine>
</Service>
</Server>
其中tomcat2的server.xml为
<?xml version='1.0' encoding='utf-8'?>
<Server port="8006" shutdown="SHUTDOWN">
<Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
<Listener className="org.apache.catalina.core.JasperListener" />
<Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
<Listener className="org.apache.catalina.mbeans.ServerLifecycleListener" />
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
<GlobalNamingResources>
<Resource name="UserDatabase" auth="Container"
type="org.apache.catalina.UserDatabase"
description="User database that can be updated and saved"
factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
pathname="conf/tomcat-users.xml" />
</GlobalNamingResources>
<Service name="Catalina">
<Connector port="8081" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
<Connector port="8010" protocol="AJP/1.3" redirectPort="8443" />
<Engine name="Catalina" defaultHost="localhost">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase"/>
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
</Host>
</Engine>
</Service>
</Server></span>
2,tomcat_server目下建立workers.properties文件,内容如下:
worker.list=tomcat1,tomcat2
worker.tomcat1.port=8009
worker.tomcat1.host=localhost
worker.tomcat1.type=ajp13
worker.tomcat1.lbfactor=1
worker.tomcat2.port=8010
worker.tomcat2.host=localhost
worker.tomcat2.type=ajp13
worker.tomcat2.lbfactor=1
# 当前域名下的所有请求都转发给ajp13w工作站处理
/www.xxx.com/*=tomcat1
/www.xxx2.com/*=tomcat2
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Apache Software Foundation\Jakarta Isapi Redirector\1.0]
"extension_uri"="/jakarta/isapi_redirect-1.2.27.dll"
"log_file"="E://tomcat_server//isapi.log"
"log_level"="debug"
"worker_file"="E://tomcat_server//workers.properties"
"worker_mount_file"="E://tomcat_server//uriworkermap.properties"
5,在IIS管理器中的“ISAPI和CGI限制”里面右键添加isapi_redirect.dll,并设定“允许执行扩展路径”,描述名可取jakarta (isapi_redirect.dll文件可以去网上下载)
6,在Default Web Site上右键添加虚拟目录,别名可取jakarta,路径指向tomcat_server目录,即isapi_redirect.dll所在目录。
7,接着单击Default Web Site,选择ISAPI筛选器,并右键添加筛选器,名称可取jakarta,可执行文件选择isapi_redirect.dll。
8,然后点击jakarta虚拟目录,双击“处理程序映射”选择“编辑功能权限...”将所有权限选上
9,然后重启IIS,启动tomcat
**由于在uriworkermap.properties文件里配置了/www.resinfo.com.cn/*=tomcat1 ,所以直接访问resinfo.com.cn的请求不会被tomcat获取,需要301重定向
下载rewrite_x64_zh-CN.msi ,是微软提供的URL重写组件,安装成功后在IIS中会出现
然后编辑Default Web Site的web.config文件, 添加如下代码
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Resinfo域名 301重定向" patternSyntax="Wildcard" stopProcessing="true">
<match url="*" />
<conditions>
<add input="{HTTP_HOST}" pattern="resinfo.com.cn" />
</conditions>
<action type="Redirect" url="http://www.resinfo.com.cn/{R:0}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
其实上述内容完全在URL重写模块填写,我由于不太熟悉怎么配置,直接手写了.
完美解决