Artykuły jmail's software

[CF]Apache przed Tomcatem z nadpisywaniem URL [en] Apache + Tomcat + mod_rewrite

przez jmail dnia May.28, 2010, w PHP / CF / .NET / Java

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 have made some researches and I’ve got it! Working solution for Apache with Tomcat and url rewriting for ColdFusion On Wheels

Assumption data:

- site folder is f:/usr/htdocs/cfpages/site
- site folder is accessible by the Apache
- our site is http://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
- 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 http://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

1
2
3
4
5
6
7
8
<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

1
2
3
4
<servlet-mapping>
        <servlet-name>CFMLServlet</servlet-name>
        <url-pattern>*.cfc</url-pattern>
</servlet-mapping>

this will rule Tomcat to serve content from rewrited 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

1
<Host name="localhost"

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

1
2
3
4
<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)

1
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

1
<VirtualHost *:80>

b/ ServerName and AliasName as usually in VirtualHost

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

c/ secure your directory from browsing the files

1
2
3
4
5
6
<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

1
RewriteEngine On

e/ Forbid open proxying

1
2
3
<LocationMatch "^[^/]">
        Deny from all
</LocationMatch>

f/ Protect proxying

1
ProxyRequests Off

g/ Give Apache a chance to rewrite url’s

1
2
ProxyPass / http://localFirstCFWheels:8100/
ProxyPassReverse / http://localFirstCFWheels:8100/

h/ Pass the oryginal host not the proxied

1
ProxyPreserveHost On

i/ use standard rewrite condition for CFWheels

1
2
3
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

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

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

1
<cfset set(urlRewriting="On")>

save and exit

11. Start Tomcat, start Apache

12. GoTo http://localFirstCFWheels and enjoy your webapp hosted on the Tomcat with full url rewrite

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

Sorry for theese 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 beggining over 300 MB of memory, and when I’ve started every each appliaction written in CF it took over 1GB of RAM! And Tomcat? Tomcat right now is making everything in about 150 MB of RAM.

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

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

:, , , , , ,

Kalendarz

May 2010
M T W T F S S
« Apr   Jun »
 12
3456789
10111213141516
17181920212223
24252627282930
31