AJP/JK:异构Web平台的集成技术

 

Tomcat Connector 可以将Tomcat与其它Web Server连接起来

 

1. AJP/JK Application Scenario:

Client ->request-> Web server (IIS, Apache) ->forward (redirect)-> Servlet in Tomcat

Response 按相反路径返回

 

2. Tomcat Configuration

Tomcat的配置比较简单,在某个port放置一个ajp的监听器即可,可以通过配置或编程来完成

配置:在conf/server.xml中,已经缺省配置了一段,在端口8009运行着一个AJP 1.3的监听器

 

<Connector port="8009" enableLookups="false" redirectPort="8443" protocol="AJP/1.3" />

你也可以自己添加一些:

<Connector port="8010" enableLookups="false" redirectPort="8443" debug="0" protocol="AJP/1.3"

useBodyEncodingForURI="true" URIEncoding="UTF-8"/>

 

编程:

 

org.apache.....CoyoteConnector ajpconn = new CoyoteConnector();
ajpconn.setProtocolHandlerClassName("org.apache.jk.server.JkCoyoteHandler");
ajpconn.setAddress(InetAddress.getHostAddress());
ajpconn.setPort(8010);
ajpconn.setMaxProcessors(10);
ajpconn.setMinProcessors(5);
ajpconn.setAcceptCount(5);
ajpconn.setConnectionTimeout(0);

org.apache.....Server server = new org.apache....Embedded( ... );

server.addConnector(ajpconn);

server.start();

 

 

3 IIS Configuration

其实是Apache为IIS开发的ISAPI Filter的配置

1. Download and Install "Jakarta Isapi Redirector"(isapi_redirect.msi,you can find more information at Tomcat-connectors)

2. 在IIS的ISAPI配置界面中,浏览并添加isapi_redirect.dll

剩下的事情就是告诉isapi_redirect.dll把哪些url转发到哪台机器的哪个端口

3. Create a new text file, rename it to "urimap.properties", or any name you like, and fill it with following content:

/stock/your.project.related.path/*=mylistener1

/webservice/Project2/*=mylistener2

4. Create a new text file, rename it to "workers.properties", or any name you like, and fill it with following content:

worker.java_home=D:/Java/j2sdk1.4.2_02

worker.list=mylistener1,mylistener2

worker.mylistener1.type=ajp13

worker.mylistener1.port=8010

worker.mylistener1.host=192.168.0.5

worker.mylistener2.type=ajp13

worker.mylistener2.port=8070

worker.mylistener2.host=192.168.0.4

5. Edit the Windows registry entry, specify the correct worker_file path as your "work.properties" path, and worker_mount_file path as your "urimap.properties" path.

HKEY_LOCAL_MACHINE/SOFTWARE/Apache Software Foundation/Jakarta Isapi Redirector/1.0 :

worker_file=c:/jakarta-tomcat/conf/workers.properties

worker_mount_file=c:/jakarta-tomcat/conf/urimap.properties

done.

 

4. Known issue

If you changed property files of "Jakarta Isapi Redirector", maybe you should restart IIS, even the host.

你可能感兴趣的:(Web)