`
kingkit
  • 浏览: 38861 次
  • 性别: Icon_minigender_1
  • 来自: 广州
文章分类
社区版块
存档分类
最新评论

IIS6与Tomcat6 整合

阅读更多

Kit.Liao 荆棘鸟设计 www.kingkit.com.cn

荆棘鸟刚买了vps,环境都得自己搭建。由于服务器同时运行asp与jsp,所以必须整合IIS与TOMCAT。

环境:Windows 2003,JDK 1.6,IIS 6,TOMCAT6,isapi_redirect-1.2.14.exe

JDK,IIS,TOMCAT怎么安装我不多说了。在IIS,TOMCAT可以正常运行web应用的前提下,我们来用JK搭通IIS与TOMCAT的天地线!

1.TOMCAT新建一个名叫test的站点,启动TOMCAT,确保能运行该站点。

2.把isapi_redirect-1.2.14.exe安装,这个安装也很简单,一路NEXT就行。我的安装路径是:C:\Program Files\Apache Software Foundation\Jakarta Isapi Redirector
下面有这几个目录。

3. 右键“我的电脑”-->-管理->服务和应用程序-->Internet信息服务(IIS),右键点击默认站点的属性页面,选择ISAPI过滤器选项卡,看看有没名为Jakarta的Jakarta Isapi Redirector,如果没有的话,就添加一个筛选器,名为jakarta,可执行文件选择刚才我们安装好的Jakarta目录下的bin的isapi_redirector.dll,确定可用。

 

4.打开Jakarta Isapi Redirector安装目录下conf文件夹中的uriworkermap.properties,在其中添加一个你需要通过IIS运行的JSP站点的名称(该站点需要在TOMCAT下的webapps目录下,并运行良好),比如:该站点名称为test,则需要加入/test/*=wlb。

5.打开IIS管理端,点击WEB扩展服务,新建一个扩展服务,其名称建议为Jakarta,浏览Jakarta Isapi Redirector安装目录下的bin,选择isapi_redirect.dll。并允许这个服务的运行。

5.重启IIS(右键“我的电脑”-->-管理->服务和应用程序-->服务,找到IIS Admin,重新启动)

6.http://localhost/test/....

如果http://localhost:8080/test/....http://localhost/test/....运行的结果一样,恭喜你!

如果有问题,也可参考一下这文章http://www.cflex.net/showFileDetails.cfm?ObjectID=296&Object=File&ChannelID=1

Connect IIS 6 to Tomcat 5

 

I needed to set up a simple distributed system consisting of an outward facing, secured IIS 6 web server and an internal, dedicated Flex server running under Tomcat 5. There is a lot of documentation out there but that in itself is a problem. It is difficult to know what really applies and what is out of date. I just successfully set up several such systems using the Tomcat <==> IIS connector. Following are the steps I took, and comments and tips about what I have learned.

 

Here is a link to the connector documentation index, if you want to do this the hard way:

http://jakarta.apache.org/tomcat/connectors-doc/

 

First the problem in a nutshell:

You can happily call your Flex applications from an IIS application (like ASP.NET) on an internal development system by using the host name (or IP address) and the port number. For example, in a custom wrapper this will work: http://myFlexServer:8080/flex/myApp/myFile.mxml. However, if you try to use that custom wrapper from outside the firewall, in other words, from the internet, you will find that port 8080, and most others, are blocked, and you cannot access your Flex application.

 

One solution is a "Jakarta Tomcat Connector", which directs calls to your Flex app through the IIS web server to the Flex/Tomcat server. You can do the same this with JRUN, and, I suspect, other J2EE servers as well. This connector allows you to use the IIS web server in the URL  to the Flex app, without requiring any port specifications to gag the firewall. So the URL  to a Flex app like in the example above becomes: http://www.myIISWebServer.com/flex/myApp/myFile.mxml.

 

How does a “connector” work? There are IIS and Tomcat parts. The Tomcat side is already set up for you in ...\Tomcat 5.0\conf\server.xml, whose job it is to create Tomcat "listeners" on specified ports. It sets up the normal listener on, for example, port 8080, but it also sets up a special listener on port 8009. In fact, if you have the Tomcat log level set to "Info" (the "Monitor Tomcat" menu/dialog, logging tab), you can look in the log: ...\Tomcat 5.0\logs\stdout.log, and see the line: "INFO: JK2: ajp13 listening on /0.0.0.0:8009"

 

But you can really just trust me, it is there.

 

On the IIS side, the connector works by using an "ISAPI" filter. This "filter" watches URL s for certain "contexts", and passes those contexts on to the specified handler dll. The simplest "context" is one of the folders under the Tomcat "webapps" folder. For example, /flex/, and /samples/ (yes, these are the folders you think) are Tomcat contexts in a default flex install.

 

Setting up IIS to use Tomcat connector

You actually have to do some work now, but not as much as you would think by reading the documentation.

 

Note: You want to be working with the “JK” connector, NOT the JK2 connector, which has been deprecated. Never mind that the log shows JK2, or that there is a jk2.properties file in the Tomcat\conf folder, and that a google search will turn up a lot of people still using JK2.

 

First, obtain the connector installer: isapi_redirect-1.2.14.exe It is available from several locations including:

http://www.devlib.org/apache/jakarta/tomcat-connectors/jk/binaries/win32/jk-1.2.14/

 

Now run the install. There does not appear to be any documentation for the installer, but here is a link to a document that describes the manual method of what the installer does, plus troubleshooting and general info, just FYI.

           http://jakarta.apache.org/tomcat/connectors-doc/howto/iis.html

 

Briefly, the install creates a folder structure and adds a few files to it, sets some registry entries, creates an IIS virtual directory, adds the isapi_redirect.dll to the IIS website ISAPI filters tab. It should take care of all the steps listed in the above howto document under "Configuring the ISAPI Redirector".

 

Next add a Web Service Extension. This needs to be done manually because the install works for IIS 5 and 6, but “Web Service Extension” only applies to IIS 6.

· Open the … Administrative Tools, Internet Information Services console.

· In the tree on the left, click ” Web Service Extensions”

· In the right hand pane, click “Add a new Web Service Extension”

· For the Extension Name, enter: Jakarta Tomcat

· Click the “Add” button.

· Browse and select C:\Program Files\Apache Software Foundation\Jakarta Isapi Redirector\bin\isapi_redirector.dll

· Click the “Allow” button. DO NOT MISS THIS STEP!

· From the “Services” MMC, restart “IIS Admin”

 

Now, the install defaults to looking for a Tomcat listener on localhost. If your Tomcat is on a different server, as mine was, you will need to make a simple edit.

 

On the IIS web server, edit:

C:\Program Files\Apache Software Foundation\Jakarta Isapi Redirector\conf\workers.properties.minimal

 

Change the line that says:

           worker.ajp13w.host=localhost

To:

           worker.ajp13w.host=www.myIISWebServer.com

You can also use an IP address. I do not know if a machine name will work.

 

Restart IIS.

 

At this stage we can test the tomcat examples, using this URL :

           http://www.myIISWebServer.com/jsp-examples/index.html

 

If it loads we are good to continue. If not, you will need to look at the troubleshooting section of the howto/iis.html document.

 

If we are good to continue, we will next add the flex “context”. The following assumes a default Flex install, with your application in:

...\Tomcat 5.0\webapps\flex

 

Adding the "flex" context:

On the IIS web server, edit:

C:\Program Files\Apache Software Foundation\Jakarta Isapi Redirector\conf\uriworkermap.properties

 

In the # [URL ]=[Worker name] section, add this line:

           /flex/*=wlb

 

Save the file.

 

Restart IIS.

 

Finally, test the connector with Flex using an URL like this:

           http://www.myIISWebServer.com/flex/myApp/myFile.mxml.

 

 

Security caveat:

In our setup, where the flex app was called from a custom wrapper in a tightly secured ASP.NET application, adding theconnector / isapi redirector had the consequence of breaking the security on the Flex app because it can be called directly from the web.

 

The ideal solution would have been for the Tomcat container’s authorization module to read the ASP.NET forms security token to permit access. Regretfully, I have not been able to make this work yet.

 

Tracy Spratt

 

 


 

 

 

 

 

<!--EndFragment-->
  • 大小: 1.5 KB
  • 大小: 81.9 KB
  • 大小: 23.1 KB
5
1
分享到:
评论
1 楼 tuohaif1 2010-10-31  
需要建一个虚拟目录,你咋没说呢?

相关推荐

Global site tag (gtag.js) - Google Analytics