How to Integrate Glassfish with IIS

After working a new project for awhile (I’m working with PHP and Java).  As a quick background story, I’m using Symfony2 and Guzzle to make my calls to my Java webservices.  This was working out great except for one minor issue.  Well, minor if you count not being able to call my REST services through Guzzle.  My problem was that IIS is running my PHP application on port 80 while my Glassfish REST services were running on port 8080 (the Glassfish default).  I needed to set up my applications forward requests to Glassfish.  So I’ll quickly guide you how to set this up.  This will work for any application server, not just Glassfish.

  1. Make sure you have Glassfish and IIS installed.  I’m using Glassfish 3.1.2 and IIS 7.5.  Any other versions should work with a few modifications.  You can download the latest version of Glassfish here and all your latest IIS needs can probably be found here
  2. Download Microsoft Web Platform Installer 3.0.  You can find a download here  After you’ve finished your download install it.
  3. After you’ve install Microsoft Web Platform Installer 3.0 you need to install Web Farm Framework.  To do this launch IIS (Click start, run, then type IIS).
  4. You should see Web Platform Installer installed in the bottom pane of IIS.  Double click on it and then do a search for Web Farm Framework.  Image
  5. Click add and then Install.  You might have a few other components that need to be installed.  Go ahead and click accept.Image
  6. Woohoo that was awfully easy.  Now navigate to the main screen of IIS.  You should have a Server Farms node.  Click on Create Server Farm in the right panel.Image
  7. Enter the name of the server farm and click next.  Click finish without adding a server.  Click yes to add routing rules for the server.
  8. Select Servers then click Add Servers on the right pane.Image
  9. Enter the IP address or server name of the server you’re adding to the farm.  In my case this is localhost.  Click on Add and this will add the server to your farm.
  10. Click on Advanced settings and select the server you’ve added.  You should see the ports that you can assign to your server. Enter your port number for HTTP and HTTPS.  I’m entering 8080 because that’s what my Glassfish Server is running on.Image
  11. Great we’re almost there.  All we have to do now is set up some routing rules.  I only want certain URLs getting routed to Glassfish.  Select your server farm and then double click on Routing Rules.Image
  12. Now just add the rules you want to exclude.  Everything else will be forwarded.  I don’t want any PHP extensions forwarded nor do I want anything that’s URL contains app_dev.php (Development purposes with PHP).  My rules look like this.Image
  13. You’re all set!  Now you can hit your Glassfish URL’s without entering the port.  This fixed one of the issues I was having with Guzzle.

Now that we’ve set this up I’ll show you how to set up Symfony2 and Guzzle so you can start writing a PHP application that makes REST calls.

About these ads

10 thoughts on “How to Integrate Glassfish with IIS

    • If you’ve followed the tutorial it should be working. Please note that in your case you do not need any rewrite rules. IIS reroutes everything by default so only add what should not be redirected. I hope that helps.

  1. What did you have to do to get the farm for 64 bit installed on windows 7? I have Win 7 pro, with IIS 7.5. Web platform installer 4.0 contains only server farm 1.1, not 2.X. I tried to install off the Microsoft site, and refused to install it.

Leave a Reply

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

You are commenting using your 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 )

Google+ photo

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

Connecting to %s