Wednesday, April 27, 2016

Configuring Tomcat-Connector for IIS 8

Configuring Tomcat-Connector for IIS 8

1. Introduction:

This page is an installation guide for the Apache tomcat 8. It tells you how to configure access to tomcat website via IIS.
This section of the guide describes the steps necessary to set up tomcat server as a windows service and then forward the website to IIS via port 80. You will do this by installing a custom ISAPI filter in IIS that understands how to use the AJP protocol (Apache JServ Protocol) to communicate with tomcat.

2. Installation:

2.1. Installation tomcat as a Windows service:

Download apache tomcat https://tomcat.apache.org/download-80.cgi
Extract the files, in this example I extracted tomcat folder under the local disk C:


Execute a command cmd and go the bin directory  

Launch service.bat command with parametres above:
service.bat install Tomacat


Checking the services for apache tomcat service


Start the service

In internet explorer, open http://localhost:8080 to check the tomcat server is running 


http://localhost:8080/examples is a tomcat simple


2.2. Install and Configure the AJP Connector:

Tomcat Connector ISAPI Filter binaries: tomcat_iis_connector.zip
  • Download the tomcat_iis_connector.zip file attached to this page. It contains the configuration files necessary for the ISAPI filter to run and communicate with your tomcat server.
  • Extract the downloaded zip file and place the contents in a folder alongside the downloaded binary file in a convenient location on your server. In this example is C:\tomcat_iis_connector.
  • If your Tomcat server is not running on the same server as IIS (for example, if tomcat is running on a non-Windows server), then edit the worker.properties.minimal file in the conf directory so that the worker.worker1.host property points to the IP address or host name of your tomcat server.
  • If you wish to change the default port for tomcat's AJP Connector, then edit the worker.properties.minimal file in the conf directory and change the worker.worker1.port property to specify the required port number. The default port used in this guide for tomcat's AJP Connector is 8009.


2.3. Add ISAPI Filter:

Open the Internet Information Services (IIS) Manager.
In the 'Connections' panel, ensure that the IIS Web Site is selected.
Double-click the 'ISAPI Filters' icon in 'Features View'.



In the 'Actions' panel on the right, select 'Add'.
Set the 'Filter name' to 'tomcat' and set the 'Executable' to the isapi_redirect.dll that you downloaded.


Click 'OK'


2.4. Add Virtual Directory

In the 'Connections' panel, ensure that the correct IIS Web Site is selected. Right-click the IIS Web Site and select 'Add Virtual Directory'


Set the 'Alias' to 'jakarta'.
Set the 'Physical Path' to the directory where you extracted the ISAPI Filter  (such as, C:\tomcat_iis_connector).
Click 'OK'


Next, select the 'jakarta' virtual directory in the 'Connections' panel.Double-click the 'Handler Mappings' icon in 'Features View'.
Click the 'Edit Feature Permissions' link in the 'Actions' panel.
Ensure that the 'Execute' option is selected.
 
In the 'Connections' panel, ensure that the local IIS Server is selected


Double-click the 'ISAPI and CGI Restrictions' icon in 'Features View'.
Click 'Add' in the 'Actions' panel.
Set the 'ISAPI or CGI path' to the isapi_redirect.dll you downloaded.
Set the 'Description' to 'tomcat'.
Ensure that the 'Allow extension path to execute' is selected.


Click 'OK'.


2.5. Pool Application configuration:

In 'Internet Information Services (IIS) Manager', go to 'Application Pools'. Select 'DefaultAppPool'
In 'Actions' click on 'Advanced Settings'

Change 'Enable 32-Bit Applications' to 'True'

    

Click 'OK'

2.6. Allow Double Escaping:

In the 'Connections' panel, ensure that the IIS Web Site that will be used is selected.
Double-click the 'Request Filtering' icon in 'Features View'.



Click the 'Edit Feature Settings' link in the 'Actions' panel. Ensure that the 'Allow double escaping' option is selected

    

Click 'OK'.

2.7. Configuration tomcat:

Modify the 'server.xml' tomcat under the conf folder
 

 Modify the 'connector' line to:

<Connector port="8009" address="127.0.0.1" enableLookups="false" redirectPort="8443" protocol="AJP/1.3" tomcatAuthentication="false" URIEncoding="UTF-8" />
 
Save 'server.xml'

3. Testing:

I have a website on IIS works on port 80 and another tomcat websit(examples) works on port 8080. I need to make sure that /examples works with IIS.

http://localhost/itgration (an IIS website)

http://localhost:8080/examples (a tomcat website)


Now, let's try to access to /examples with IIS (Port 80)



23 comments:

  1. I am able to see JSP pages with these settings but not Serverlets output.IS there any thing I missed in my IIS settings

    ReplyDelete
  2. Love you man!! I was almost becoming crazy because I wasn't able to manage this problem... Thank you so much for you the post!!

    ReplyDelete
  3. This was awesome! Do you know how i can then create a custom URL to load the page?

    ReplyDelete
  4. I deploy this workflow with Tomcat installed on Linux but its not worked for me
    is there any additional configuration for Linux RH ?

    ReplyDelete
  5. Pure genius. It worked. This makes my setup so much easier. Thank you!!

    ReplyDelete