Download and install java sdk ( I used 1.6.17 ) ( note you need the JDK not JRE )
Download glassFish
Download ColdFusion 8 or 9
Download Apache

I used Windows Server 2008 64bit but the process is the same for 32bit or Win 2k3.  It's also ( obviously ) different on linux or unix but not majorly.

When installing glassFish did not detect java home correctly so I provided the location via the cmd line.



The install is very straight forward I did not select anything unusual and just clicked through:


Once glassFish was installed I started the server:




Then browse to:  http://127.0.0.1:4848 to get to the admin console.



I choose to leave the admin with no authentication so it will just load to the console.

Before you look at the console we will need to create a ColdFusion war.  Run the ColdFusion installer and select "JEE Configuration"


This will produce the war file ready for deployment.  For me the output was c:\coldFusion9\cfusion.war

Now go back to the control panel.  Select "Applications" from the menu.  Then select "Deploy".  Choose a file from the local file system and leave the name as cfusion.



Once the application is deployed we can launch it by clicking launch button and you will see:


404 error's.  This is because there are no .cfm files if you went to /CFID/administrator you would would be at the CFADMIN.

I'll skip the CFADMIN and make a index.cfm:

Contaning:






Reload the Original page that was launched by clicking "Launch"


And ColdFusion 9 is running on GlassFish.

This is on port 8080 but I want it to run behind apache on port 80 without the /cfusion

Make sure IIS is not running. Install Apache.  Apache for windows come with all the modules you're likely to need but most are commented out.  Test to make sure Apache is runnign and http://127.0.0.1 should the standard message "It works".

Now we will setup the proxy.

Around line 110 of httpd.conf uncomment 2 modules mod_proxy.so and mod_proxy_connect.so



Also un-comment


Open {apacheInstallDir}\conf\extrahttpd-vhosts.conf

create a new vhostBlock


I created a dummy entry in the Windows host file so http://cf9gf resolves locally. I'll be using this as the test domain.

Restart apache and look for errors.



If there are no errors you should now be ready to proxy from apache to glassFish on port 80.



Done.

Now GlashFish is no longer listed here: http://www.adobe.com/products/coldfusion/systemreqs/ but it still works fine.

Also note the /flex2gateway works fine aswell.

28 comments:

Rahul said...

good one !

as always very clear and simple to follow.

Rahul.

Chris said...

I'm getting a 404 error with the /flex2gateway. Any ideas on that?

Chris said...

Nevermind, stupid error on my end.

Franklin May said...

This config coud be used with CF8 and Glasfish 2.x?

Paul Kukiel said...

Yes it would work the same way with GF 2.

mrt181 said...

Hmm, the apache part does not work, i get an 500 error the moment i un-comment
"Include conf/extra/httpd-vhosts.conf"

Paul Kukiel said...

Perhaps you made a typo in the httpd-vhosts.con file. Can you paste the code?

mrt181 said...

this is what i have added to my http-vhosts.conf removed the tag smybols <>:

virtualhost *:80
DocumentRoot "C:\dev\cfusion"
ServerName cfusion
ProxyRequests Off
proxy *
Order deny,allow
Allow from all
/Proxy
ProxyPass / http://127.0.0.1:8080/cfusion/
ProxyPassReverse / http://127.0.0.1:8080/cfusion/
ErrorLog "logs/cfusion.local-error.log"
CustomLog "logs/cfusion.local-access.log" common
/VirtualHost

virtualhost *:80
DocumentRoot "C:\dev\cfusion"
ServerName railo
ProxyRequests Off
proxy *
Order deny,allow
Allow from all
/Proxy
ProxyPass / http://127.0.0.1:8080/railo/
ProxyPassReverse / http://127.0.0.1:8080/railo/
ErrorLog "logs/railo.local-error.log"
CustomLog "logs/railo.local-access.log" common
/VirtualHost

Paul Kukiel said...

That looks fine. Does http://127.0.0.1:8080/cfusion/ work?

mrt181 said...

Yes http://127.0.0.1:8080/cfusion and http://127.0.0.1:8080/railo/index.cfm work without any problem

mrt181 said...

This line causes the 500 error:
ProxyPass / http://127.0.0.1:8080/cfusion/
Without it the default Apache site will be displayed but the url rewrite does not work

Paul Kukiel said...

mod proxy must not be available. In httpd.conf un comment these lines:

LoadModule proxy_module modules/mod_proxy.so

LoadModule proxy_connect_module modules/mod_proxy_connect.so

mrt181 said...

They are un-commented. I use Apache 2.2.14...

Paul Kukiel said...

Tried re-starting Apache?

mrt181 said...

sure

mrt181 said...

Stupid me. I had to un-comment the mod_proxy submodule for http.

Paul Kukiel said...

LoadModule proxy_http_module modules/mod_proxy_http.so

Oh yeah this is needed aswell. I forgot to include that in the post.

mrt181 said...

have you tried to access the coldfusion adminstrator interface?

I have followed your guide and see the server dump when i enter this into the browser:

http://adobe/index.cfm

But when i try to get into the CF9 Admin Interface:
http://adobe/CFIDE/administrator/index.cfm

I see the login page without images and when i enter my password i am redirected to:
http://adobe/cfusion/CFIDE/administrator/enter.cfm

The only difference to your setup is the ServerName adobe instead of cf9gf. What's going on?

Railo works without any problem!

Paul Kukiel said...

Yep that happened to me aswell. I just used 127.0.0.1:8080/cfusion/cfide/administrator to get the un-broken admin.

mrt181 said...

Hey, i use this now in my httpd-vhosts.conf.

ServerName adobe
RewriteEngine On
RewriteOptions Inherit
RewriteRule ^/(.*) http://127.0.0.1:8080/$1 [P,L]
ProxyPassReverse / http://127.0.0.1:8080/
ProxyPreserveHost On

Now i can reach the CF9 Admin through http://adobe/cfusion//cfide/administrator/index.cfm and it works.

Any idea how to tell railo and adobe to share the same contex root on a windows platform?

Paul Kukiel said...

You can't I wanted to ideally do the same thing so I could use the exact same code for both CF9 and Railo but I wasn't able to do it.

mrt181 said...

I have added this mapping to both:

/dev c:/dev/cfusion/

Railo understands this but Adobe does not resolve the mapping!?

Scott Stroz said...

@Paul - great write up, got this working in about 1/3 the time I expected.

One question, though. I like to set up my dev sites as their own 'domain' in Apache - like myproject.dev and point the vhost to the dir where the files for that project are kept. it seems that setting up Glassfish with Apache the way to outlined that is not possible (or at least, not obvious). Can you shed some light on how to do this...if its even possible?

Paul Kukiel said...

@Scott I would deploy a 2nd instance of ColdFusion war and set the virtual host to that. Although this is going to chew up RAM. There are ways to make Tomcat server wide but I'm not sure how to with Glassfish. If I come up with something I'll follow up.

Rodion said...

Hello,

thanks for explanations!

Did you find way to move wwwroots for CF9 and Railo out of glassfish installation directory ? Like having Apache's /htdocs folder common storate for Apache, CF and Railo ? In Resin or Tomcat I'd fix clause for Railo... Don't want to have 3 different folders for development code :-)

Paul Kukiel said...

@Rodion No I haven't. I'm not sure its possible to do that perhaps on linux with symlinks

Rodion said...

@Paul, there's solution for document root problem: http://www.marceble.com/2009/07/virtual-directories-in-glassfish/

Paul Kukiel said...

@Rodion Wow thanks. That's a great solution.

Post a Comment