Sharing the Point

Office 365, SharePoint, Project Server – Blog

How to Configure IIS 7 and Tomcat Redirection on Windows Server 2008 (64 Bit)

Posted by Ashraf on September 20, 2010

Objective: To provide a Secure Server Environment and Running non IIS compatible extensions like jsp in IIS Web server.

Check Before you Start:

JDK 1.6
IIS 7.5
Tomcat 6.0.18
Isapi_redirect.dll (64bit) version 1.2.28

Steps to follow:

Install Jdk 6

Download and install JDK 6 with its default setup options.
Now, go to Computer>Properties>Advanced System Settings>Advanced Tab>Environment Variables

Set System Variables (JAVA_HOME and CATALINA_HOME)

Click New, enter name as JAVA_HOME and your jdk installation path as variable value; click OK.

set java_home variable

set java_home variable

Select PATH and click Edit. Add the java installation path after the current value with a semicolon (;). Click OK, when done.

set java path

set java path

Click New, enter name as CATALINA_HOME and your Tomcat installation path as variable value; click OK.

set catalina_home

set catalina_home

Install Tomcat 6.0.18

Install Tomcat with default settings and test running the URL as http://localhost:8080

tomcat running on port 8080

tomcat running on port 8080

Tomcat setup is working on port 8080.

Setting up Registry value

1. Download the isapi_redirect.dll from the Tomcat site for Windows Server 2008 R2 64 bit from the following URL.
http://www.apache.org/dist/tomcat/tomcat-connectors/jk/binaries/win64/jk-1.2.28/amd64/

2. Rename the isapi_redirect-1.2.28.dll to isapi_redirect.dll
3. Copy the isapi_redirect.dll to C:\Program Files (x86)\Apache Software Foundation\Tomcat 6.0\bin\
4. Run Regedit as Administrator
Find the key [HKEY_LOCAL_MACHINE\SOFTWARE\Apache Software Foundation\
Make one new key entry as “Jakarta Isapi Redirector” then another new key entry name “1.0” then under that make 6 new string values.

setup registray value for Isapi_Redirect dll

setup registray value for Isapi_Redirect dll

NOTE: If “Apache Software Foundation” folder does not exist in the hierarchy mention here then create the path manually. So, the hierarchy will resemble the following.
[HKEY_LOCAL_MACHINE\SOFTWARE\Apache Software Foundation\Jakarta Isapi Redirector\1.0]

Registry Key  and  Value

@=

extension_uri = /jakarta/isapi_redirect.dll

log_file = C:\Program Files (x86)\Apache Software Foundation\Tomcat 6.0\logs\isapi_redirect.log

log_level = error

worker_file = C:\Program Files (x86)\Apache Software Foundation\Tomcat 6.0\conf\workers.properties.minimal

worker_mount_file = C:\Program Files (x86)\Apache Software Foundation\Tomcat 6.0\conf\uriworkermap.properties

Install and Configure IIS Role

1. Add iis role

Add IIS Features

Add IIS Features

Add IIS Features

Add IIS Features

Click Next and Finish the installation.
You can check wheter the iis works or not by addressing your browser to http://localhost.

iis7 running at localhost

iis7 running at localhost

Now the IIS works fine, we will go to the next steps.

2. Setup isapi & cgi restriction at iis server

A. Open IIS Manager and Select Your Server
B. From the features view open ISAPI and CGI Restrictions, Click Add from the Actions bar

Setup isapi & cgi restriction

Setup isapi & cgi restriction

C. For ISAPI or CGI Path click the … Button and choose your isapi_redirect.dll file at your tomcat installation folder (C:\Program Files (x86)\Apache Software Foundation\Tomcat 6.0\bin\).

Setup isapi & cgi restriction

Setup isapi & cgi restriction

D. In the Description Field write “isapi_redirect”
E. Tick the Allow extension path to execute and click OK.

3. Enable isapi filters at iis default website

F. Select Default Website and double click ISAPI Filters to open it. Click Add

Enable isapi filters at iis default website

Enable isapi filters at iis default website

G. Enter “jakarta” in the filter name And click …Button to to select the isapi_redirect.dll.

H. Click open to select the dll and Ok to close the window when done.

4. Creating Virtual directory and handler mappings

I. Right click to the Default website and choose Add Virtual Directory…

J. Enter “jakarta” in the Alias field and choose the path of the “isapi_redirect.dll” file (C:\Program Files (x86)\Apache Software Foundation\Tomcat 6.0\bin\) as Physical path.

set virtual directory path

set virtual directory path

K. Click ok when done.
L. Now, Open Handler mappings by selecting the virtual directory “Jakarta”.

jakarta handler mapping

jakarta handler mapping

M. Select Edit Feature Permission from the Actions bar and Check All (Read, Script, and Execute) and click OK.

Creating properties file

Now create two properties FILE AS follows:
1. Create a file named “workers.properties.minimal” in the “conf” folder which you can find in the tomcat installation folder.
2. Insert the following lines into this file:

worker.list = worker1
worker.worker1.host=localhost
worker.worker1.port=8009
worker.worker1.type=ajp13

3. Create another file named “uriworkermap.properties” in the same directory. Insert this line and save.

/*=worker1

Test and Run

4. Restart the Tomcat Service and the IIS Web-Server

5. Test the configuration by trying to access the iis site(http://localhost), if you get Tomcat site then you are done successfully.

tomcat running at iis

tomcat running at iis

Hope this helps.

31 Responses to “How to Configure IIS 7 and Tomcat Redirection on Windows Server 2008 (64 Bit)”

  1. Rajesh said

    Really gr8 and very very useful helpful article, thank a lot..

  2. Ashish Raichura said

    Really great, screens helps lot. Question: What if my tomcat is not on 8080 and on different port say 11500. I tried but not working can you able to help me ?

  3. Ashraf said

    Hi Ashish,
    I think you can first try with the default port and then try to change the port. Most probably you have to do something on the worker file specially at localhost, not 100% sure because i never try this. Thanks

  4. Scott Tansley said

    Hi,

    Spent two days trying to get SSL to work on Tomcat. Eventually gave up and did it on IIS, and then needed to connect Tomcat to that. You’re instructions have helped me massively, as a first timer. They were communicated really well.

    Thanks so much for taking the time to write this!

    Regards,

    Scott

  5. Marcos Mariano said

    Hey, very cool tutorial man. But, i still have a problem, i cant run jsp files on my server. html works fine, but when i go to jsp pages, i got error 404.
    Can u help?

    • Ashraf said

      Hello Marcos,
      Thanks for your comment. The 404 resembles the page is not found. can you access the jsp pages directly from tomcat? if it goes ok then please try with work file and allow everything to be browsable through iis.
      Hope this helps. Please feel free to contact. thanks again.

  6. Jonathan said

    Thank you for this, this was extremely useful.

  7. asif said

    Hi, This is helpfull tutor. but when i configure tomcat, IIS not working no asp and aspx is working. I made vartual folder for asp and aspx page. its is redirecting tomcat. pleas tell how same website tomcat and iis will work for jsp and asp page.

    thanks

    • Ashraf said

      Hi Asif,
      if you configure this way ever request on iis will forward to tomcat. you need to setup in the worker for which it iis will forward to tomcat. hope this helps.

      • asif said

        Thanks for prompt reply, Can tell me steps to setup throug worker. I want same website one vartual directory for jsp and another vartual disrectory for aspx . Please tell me the process.
        Thanks

      • Ashraf said

        Hello Asif,
        Please follow this linkhttp://tomcat.apache.org/connectors-doc-archive/jk2/jk/iishowto.html and read Advanced Worker Configuration carefully. As you have application in iis you have to forward specific folder/file request to the tomcat(host) rather then redirect everything. you have to use something like the following for worker,

        you can use these workers to serve two different contexts/applications each with its own worker :
        /examples/*=worker1, this will reply the tomcat examples applications
        /webpages/*=worker2 , this will reply the webpages

        so configure as per your need. this is just for your idea.thanks

      • Ashraf said

        Asif,

        /*=worker1 will redirect everything to tomcat. Suppose you want to redirect to specific application request to tomcat then i think you can use something like follows,

        /your application/*=worker1

        Let me know your status.

  8. asif said

    I am still strugling to setup. thanks ashraf.i will try again.

  9. asif said

    Thank You very much. I have solved the problem. Thank You

  10. windows said

    shareware…

    How to Configure IIS 7 and Tomcat Redirection on Windows Server 2008 (64 Bit) « Ashraf's Share Point…

  11. bhagyashree said

    After following all steps.. i am getting

    HTTP Error 500.0 – Internal Server Error
    Calling LoadLibraryEx on ISAPI filter “C:\Program Files\Apache Software Foundation\Apache Tomcat 6.0.14\bin\isapi_redirect.dll” failed

  12. bhagyashree said

    After following all steps.. i am getting

    HTTP Error 500.0 – Internal Server Error
    Calling LoadLibraryEx on ISAPI filter “C:\Program Files\Apache Software Foundation\Apache Tomcat 6.0.14\bin\isapi_redirect.dll” failed
    so let me know.. where i am wrong

  13. Bharath said

    This worked thanks..

    I have my webapp in e:\test

    I created a new site in IIS with path to e:\test and i congifured jakarta i get the first page (login page) and after i click the button i get ” HTTP Status 404 /web/validate.jsp ”

    description The requested resource (/PramWeb/ValidateLogin.jsp) is not available.

  14. [...] Kalau mau tau konfigurasi IIS dengan Tomcat, bisa refer ke sini [...]

  15. alexis said

    Hi

    I tried to follow your step by step tutorial for configuring jsp in IIS but unfortunately I’m stuck because i can’t find any isapi_redirect.dll

    can anyone please send me a link…

    Thanks

    Alexis

    • Ashraf said

      do you download it from the mentioned URL?

      • alexis said

        Hello Ashraf

        Thanks for the reply, the URL you’ve mentioned is broken.

        It say’s

        Not Found

        The requested URL /dist/tomcat/tomcat-connectors/jk/binaries/win64/jk-1.2.28/amd64/ was not found on this server.

        Apache/2.3.15-dev (Unix) mod_ssl/2.3.15-dev OpenSSL/1.0.0c Server at http://www.apache.org Port 80

      • Ashraf said

        Actually i didn’t try this URL recently but this was working when i did this stuffs. You can search internet and can email them for the latest.thanks

  16. Mauno said

    This was great. In older versions, the regedit was not necessary, and so I tried without editing registry.
    So I have a new problem: IIS 7.5 returns just the bytes in isapi_redirect.dll (and browsers ask what to do with it – open or save).
    Then did the regedt, but with no luck.

    • Armando said

      I’ve the same problem!!!

      Did you managed to fix it??? I have followed all the steps, several times and have tried with diferent Tomcat servers and when IIS redirect it returns only a binay file…

      I’m using Windows 2008 R2 Server (64bits) with IIS7.5 and redirecting to Tomcat 6 (Alfresco in it) and Tomcat 7… but it doesn’t work.

      Using DLL version 1.2.36 for 64 bits, downloaded from “http://www.apache.org/dist/tomcat/tomcat-connectors/jk/binaries/windows/”

  17. miguel said

    Very good! thanks

  18. miguel said

    Hello,
    I had some trouble to make it work until I saw:

    If you must use a 32 bit IIS connector, you can do so by clicking Application Pools > Advanced Settings > Allow 32bit applications

    (from http://confluence.atlassian.com/display/JIRA/Integrating+JIRA+with+IIS)

    And it started to work
    Hope this help anyone with this problem.

  19. Denis Tse said

    Awesome step-bystep.

    It worked in the first time!

    A little but usefull comment:

    to redirect a specific realm, alter the uriworkermap.properties with the desired realm to be redirect:

    /examples/servlets/*=worker1
    /examples/jsp/*=worker1

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

 
Follow

Get every new post delivered to your Inbox.

Join 59 other followers