[cfwheels] Apache with Tomcat and url rewriting

Hell YES. This ^&(%^989&^%*(% Tomcat is now working for me like a bleeding
pig. Hell YES!!! 12 hours of making this shit working. I am dying :F

I haven't found anywhere instruction so I put this in here

Assumption data:

— site folder is f:/usr/htdocs/cfpages/site
— site folder is accessible by the Apache
— our site is localFirstCFWheels
— no mod_jk no mod URLFilter or how this shit is called
— pure apache rewrite rules
— Apache Tomcat 6.0.26 Server
— Apache 2.2.13 (and later)
— Railo 3.1.2.001
— Apache Tomcat is configured to listen on 8100 port

1. You need to install tomcat and railo (railo as a module — i don't know
how to call it. :D) good instruction in it is in here
corfield.org/entry/Railo_on_Tomcat__multiweb (just don't make this
part with hosts — we will make this in here)
2. You need to install apache
with mod_rewrite and mod_proxy and mod_proxy — there are a lot of tutorials
about it just find in google
3. When you've got everything working then stop
both servers (Tomcat and Apache)
4. Go to the web.xml file located in
Tomcat_Install_Path/conf end open it in editor 5. Find this place with
servlet-mapping (you were configuring this in the 1. )

6. Add

<servlet-mapping>
       <servlet-name>CFMLServlet</servlet-name>
       <url-pattern>/index.cfm/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
       <servlet-name>CFMLServlet</servlet-name>
       <url-pattern>/rewrite.cfm/*</url-pattern>
</servlet-mapping>



After

<servlet-mapping>
       <servlet-name>CFMLServlet</servlet-name>
       <url-pattern>*.cfc</url-pattern>
</servlet-mapping>



this will rule Tomcat to serve content from rewritten URL. Save web.xml and
close

7. Go to the server.xml file located in Tomcat_Install_Path/conf end open it
in editor. Scroll down to the end of the file and find something like this


<Host name="localhost"



Scroll down to the last added host and add another one:


<Host name="localFirstCFWheels" appBase="webapps">
 <Context path="" docBase="f:/usr/htdocs/cfpages/site"/>
 <Alias>www.localFirstCFWheels</Alias>
</Host>



this will rule Tomcat to launch new host. Save server.xml and close

8. (on windows / xampp any system) Open ApacheInstallPath/conf/ httpd.conf
and uncomment (or add at the end of the file)

Include conf/extra/httpd-vhosts.conf

9. (on windows / xampp any system) Open ApacheInstallPath/conf/extra/
httpd-vhosts.conf and create new Virtual Host (If you are new to
VirtualHosts on Apache first find the tutorial on it)


a/ declaration

<VirtualHost *:80>

b/ ServerName and AliasName as usually in VirtualHost

ServerName localFirstCFWheels
ServerAlias localFirstCFWheels
DocumentRoot "f:/usr/htdocs/cfpages/site"
DirectoryIndex index.cfm

c/ secure your directory from browsing the files

<Directory "f:/usr/htdocs/cfpages/site/">
   Options -Indexes FollowSymLinks
   AllowOverride All
   Order allow,deny
   Allow from all
</Directory>

d/ Turn on rewrite engine for that host

RewriteEngine On

e/ Forbid open proxying

<LocationMatch "^[^/]">
       Deny from all
</LocationMatch>

f/ Protect proxying

ProxyRequests Off

g/ Give Apache a chance to rewrite url's

ProxyPass / http://localFirstCFWheels:8100/ ProxyPassReverse /
http://localFirstCFWheels:8100/

h/ Pass the original host not the proxied

ProxyPreserveHost On

i/ use standard rewrite condition for CFWheels

RewriteCond %{REQUEST_URI} !^.*/(flex2gateway|jrunscripts|cfide|
cfformgateway|railo-context|files|images|javascripts|miscellaneous|
stylesheets|robots.txt|sitemap.xml|rewrite.cfm)($|/.*$) [NC]

j/ and the last but not the least make rewrite rule

RewriteRule "^/(.*)" http://localFirstCFWheels:8100/rewrite.cfm/$1
[P,QSA,L]



10. Go to your cfwheels site, open the settings.cfm file add

<cfset set(urlRewriting="On")>


save and exit

11. Start Tomcat, start apache

12. Go to localFirstCFWheels and enjoy your webapp hosted on the
Tomcat with full URL rewrite

Why have I tested this and written this instruction? The answer is very
simple. I still haven't found the option to install Railo on GlassFish as a
web module. And the Resin…

Sorry for these words but Resin is just a piece of shit good for developing
but not for production. Maybe If you've got one site or something. I've got
a site with over 60.000 unique visitors per day.
On the same machine I've got the Apache with PHP and IIS with .NET and I've
got GlassFish which I must have. I have put there Resin and started it. And
that was the major mistake in my life. Resin has took at the beginning over
300 MB of memory, and when I've started every each application written in CF
it took over 1GB of RAM! An Tomcat?
Tomcat right now is making everything in about 150 MB of RAM.

And the most important information is that Tomcat is much much faster then
Resin. Reload of application took almost the same time as other operations.

As for now I am sure that I will be trying to find way to install Railo on
GlassFish, but I have found a wonderful alternative and a wonderful
production server for my ColdFusion apps.

regards, © jmail

Comments (1)

RSS Collapse / Expand
+
0
So man, you are doing so serious shit out here :) I gotto learn some too :)
avatar

turalo

  • June 7, 2010, 2:43am

Only registered and authorized users can leave comments. Login or Register