Tomcat Connector can connect tomcat to other web servers
1. AJP/JK Application Scenario:
Client-> Request->Web Server (IIS, Apache)-> Forward (redirect)->Servlet in Tomcat
Response Return in the opposite path
2. tomcat configuration
Tomcat configuration is relatively simple. You can place an AJP listener on a port, which can be completed through configuration or programming.
Configuration: In CONF/server. XML, a listener of AJP 8009 is running on port 1.3 by default.
|
<Connector Port = "8009" enablelookups = "false" redirectport = "8443" protocol = "AJP/1.3"/>
You can also add some:
<Connector Port ="8010"Enablelookups =" false "redirectport =" 8443 "DEBUG =" 0 "protocol =" AJP/1.3"
Usebodyencodingforuri = "true" uriencoding = "UTF-8"/>
|
Programming:
|
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
In fact, it is the configuration of ISAPI filter developed by Apache for IIS.
1. Download and install "Jakarta ISAPI redirector" (isapi_redirect.msi, you can find more information at tomcat-connectors)
2. On the ISAPI configuration page of IIS, browse and add isapi_redirect.dll
The rest is to tell isapi_redirect.dll which URLs are forwarded to which machine and which port
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 shoshould restart IIS, even the host.