coldbox, tomcat, and SES urls

279 views
Skip to first unread message

sc...@bugleme.com

unread,
Apr 3, 2010, 1:15:56 PM4/3/10
to ColdBox Platform
Hello,

I know this topic has come up before, but I can't find a definitive
answer anywhere. I would like to use Apache, Tomcat 6, Coldfusion 9,
and Coldbox 3.0 for my application, and I want to use SES urls. The
problem comes when trying to proxy a request from Apache to tomcat
that looks like /index.cfm/handler/function -- because that is not a
real file or path.

I've seen a solution that involves some new rewrite rules, and
extension of the SES interceptor, but I couldn't ever get that to
work, and CB3.0 seems ever more different. Will Coldbox ever
officially support this method?

In the Coldbox book (written for 2.6.3), Luis comments that it should
be easy to overcome the tomcat (or jetty or...) limitiation by
creating a servlet mapping for index.cfm. Has anyone used this? I'm
not an expert on servlets or tomcat -- can anyone provide more details
on this implementation?

I can't be the only person to want to use SES urls on a non-jrun
implementation. How are you all doing it?

Thanks,
Scott

Luis Majano

unread,
Apr 6, 2010, 11:40:19 AM4/6/10
to col...@googlegroups.com
Here is some info for you.  This is not coldbox related but server setup related.
Tomcat/Jetty and other by the book servelt containers do not allow the full SES mappings, so you have to do a little more.  There are several posts out there that can show you how to do it. Here are some guides

http://tech.tjandrawibawa.org/blog/2009/11/06/railo-on-apache-tomcat-windows-part-3-getting-url-rewriting-works-for-coldbox/

The easiest approach you can do is open the tomcat web.xml and add the servlet mapping for this:  index.cfm/*

Then you can proxy results from apache to tomcat using this approach.

Read this also:
http://forums.coldboxframework.com/index.cfm?event=ehMessages.dspMessages&threadid=9D95C883-FF65-CEF6-655A32868AE05487

Luis F. Majano
President
Ortus Solutions, Corp

ColdBox Platform: http://www.coldbox.org
Linked In: http://www.linkedin.com/pub/3/731/483
Blog: http://www.luismajano.com
IECFUG Manager: http://www.iecfug.com


--
You received this message because you are subscribed to the Google Groups "ColdBox Platform" group.
To post to this group, send email to col...@googlegroups.com
To unsubscribe from this group, send email to coldbox-u...@googlegroups.com
For more options, visit this group at http://groups-beta.google.com/group/coldbox
For News, visit http://blog.coldbox.org
For Documentation, visit http://wiki.coldbox.org

To unsubscribe, reply using "remove me" as the subject.

Sean Corfield

unread,
Apr 7, 2010, 3:29:26 AM4/7/10
to col...@googlegroups.com
On Sat, Apr 3, 2010 at 10:15 AM, sc...@bugleme.com <sc...@bugleme.com> wrote:
> I know this topic has come up before, but I can't find a definitive
> answer anywhere. I would like to use Apache, Tomcat 6, Coldfusion 9,
> and Coldbox 3.0 for my application, and I want to use SES urls. The
> problem comes when trying to proxy a request from Apache to tomcat
> that looks like /index.cfm/handler/function -- because that is not a
> real file or path.

You can easily configure Tomcat to process /index.cfm/* as a URL so it
handles these SES URLs. I'm working on a large ColdBox app right now
that uses SES URLs throughout, running on Tomcat.
--
Sean A Corfield -- (904) 302-SEAN
Railo Technologies, Inc. -- http://getrailo.com/
An Architect's View -- http://corfield.org/

"If you're not annoying somebody, you're not really alive."
-- Margaret Atwood

Coldwell, Scott

unread,
Apr 19, 2010, 9:38:48 AM4/19/10
to col...@googlegroups.com
Thanks Sean and Luis. I now have a servlet-mapping setup. Is there something I need to do to get CF to interpret the pages? If I hit the actual file path, cfml is interpreted, but if I use the servlet mapping, the code itself is returned as plain text.

Thanks again,
Scott



--
You received this message because you are subscribed to the Google Groups "ColdBox Platform" group.
To post to this group, send email to col...@googlegroups.com
To unsubscribe from this group, send email to coldbox-u...@googlegroups.com
For more options, visit this group at http://groups-beta.google.com/group/coldbox
For News, visit http://blog.coldbox.org
For Documentation, visit http://wiki.coldbox.org

To unsubscribe, reply using "remove me" as the subject.

Sean Corfield

unread,
Apr 20, 2010, 3:16:35 AM4/20/10
to col...@googlegroups.com
Show us your servlet-mapping - sounds like you haven't got it set up right.

On Mon, Apr 19, 2010 at 6:38 AM, Coldwell, Scott <sc...@bugleme.com> wrote:
> Thanks Sean and Luis. I now have a servlet-mapping setup. Is there something
> I need to do to get CF to interpret the pages? If I hit the actual file
> path, cfml is interpreted, but if I use the servlet mapping, the code itself
> is returned as plain text.

--
You received this message because you are subscribed to the Google Groups "ColdBox Platform" group.
To post to this group, send email to col...@googlegroups.com
To unsubscribe from this group, send email to coldbox-u...@googlegroups.com
For more options, visit this group at http://groups-beta.google.com/group/coldbox
For News, visit http://blog.coldbox.org
For Documentation, visit http://wiki.coldbox.org

Subscription settings: http://groups.google.com/group/coldbox/subscribe?hl=en

Coldwell, Scott

unread,
Apr 20, 2010, 9:49:20 AM4/20/10
to col...@googlegroups.com
My application is under webapps/ROOT

I added my servlet mapping after the standard one:

    <!-- This was already there --->
    <servlet-mapping>
        <servlet-name>default</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>

    <!-- This is my new, shiny mapping --->
    <servlet-mapping>
       <servlet-name>default</servlet-name>
       <url-pattern>/index.cfm/*</url-pattern>
    </servlet-mapping>


Thanks,
Scott

Sean Corfield

unread,
Apr 26, 2010, 3:40:45 AM4/26/10
to col...@googlegroups.com
On Mon, Apr 19, 2010 at 6:38 AM, Coldwell, Scott <sc...@bugleme.com> wrote:
> Thanks Sean and Luis. I now have a servlet-mapping setup. Is there something
> I need to do to get CF to interpret the pages? If I hit the actual file
> path, cfml is interpreted, but if I use the servlet mapping, the code itself
> is returned as plain text.

OK, I saw your servlet-mapping and it looked fine.

When you say "If I hit the actual file path, cfml is interpreted, but
if I use the servlet mapping, the code itself is returned as plain
text.", could you be more specific?

What URLs *exactly* are you hitting?

Without the servlet-mapping, you'd just get a file not found error from Tomcat.

Perhaps your Apache setup is not correct?
--
Sean A Corfield -- (904) 302-SEAN
Railo Technologies, Inc. -- http://getrailo.com/
An Architect's View -- http://corfield.org/

"If you're not annoying somebody, you're not really alive."
-- Margaret Atwood

--
You received this message because you are subscribed to the Google Groups "ColdBox Platform" group.
To post to this group, send email to col...@googlegroups.com
To unsubscribe from this group, send email to coldbox-u...@googlegroups.com
For more options, visit this group at http://groups-beta.google.com/group/coldbox
For News, visit http://blog.coldbox.org
For Documentation, visit http://wiki.coldbox.org

Subscription settings: http://groups.google.com/group/coldbox/subscribe?hl=en

Coldwell, Scott

unread,
Apr 26, 2010, 12:24:09 PM4/26/10
to col...@googlegroups.com
Hi Sean,

I created a file called test.cfm that lives in the root. It merely dumps the value now().

When I hit http://localhost:8080/test.cfm, I get a timestamp, e.g.

{ts '2010-04-26 11:17:00'}

When I hit http://localhost:8080/index.cfm/test.cfm, I get code returned in plain text:

<cfdump var="#now()#"/>

All of this is hitting tomcat directly. I get the same results if I proxy from Apache.

I've tried putting the servlet-mapping definition in tomcat/conf/web.xml and also in WEB-INF/web.xml. The results are the same.

Thanks,
Scott

Sean Corfield

unread,
Apr 26, 2010, 6:18:55 PM4/26/10
to col...@googlegroups.com
On Mon, Apr 26, 2010 at 9:24 AM, Coldwell, Scott <sc...@bugleme.com> wrote:
> When I hit http://localhost:8080/index.cfm/test.cfm, I get code returned in
> plain text:
>
> <cfdump var="#now()#"/>

Well, /index.cfm/test.cfm doesn't make sense as a URL. I'm not even
sure what it would try to run... maybe /index.cfm with the string
"/test.cfm" in CGI.PATH_INFO? Or maybe it would look for a directory
called "index.cfm" in the web root and try to run test.cfm inside
that?

At this point, without access to your server - or a lot more
information from you - it's really hard to say what might be
misconfigured (but it's definitely a misconfiguration since SES URLs
work just fine on Tomcat for a variety of frameworks).

Coldwell, Scott

unread,
Apr 27, 2010, 4:30:08 PM4/27/10
to col...@googlegroups.com

On Mon, Apr 26, 2010 at 5:18 PM, Sean Corfield <seanco...@gmail.com> wrote:

> Well, /index.cfm/test.cfm doesn't make sense as a URL.

Isn't that the point of this discussion? I thought that the servlet mapping was to 'trick' tomcat into thinking that was a valid url?


> At this point, without access to your server - or a lot more
information from you - it's really hard to say what might be
misconfigured (but it's definitely a misconfiguration since SES URLs
work just fine on Tomcat for a variety of frameworks).

I'm not sure where to go from here - this wasn't supposed to be difficult. I have tomcat, straight out of the box, with an added servlet mapping in tomcat/conf/web.xml (should I delete any existing mappings?). The code all lives under the ROOT webapp (other folders in webapps have been deleted).

In apache, i'm using mod_ajp to proxy requests to tomcat using modified Coldbox .htaccess rules:

        #Images, css, javascript and docs, add your own extensions if needed.
        RewriteCond %{REQUEST_URI} \.(bmp|gif|jpe?g|png|css|js|txt|pdf|doc|xls|xml|ico|php|asp|htm|html|xml|swf)$
        RewriteRule ^(.*)$ - [NC,L]

        #The ColdBox index.cfm/{path_info} rules.
        RewriteRule ^$ index.cfm [QSA]

        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule ^(.*)$ ajp://localhost:8009/index.cfm%{REQUEST_URI} [P,L] #this is the only modified line

I'm sure I'm missing something brutally obvious. I appreciate your patience.

Thanks,
Scott

Judah McAuley

unread,
Apr 27, 2010, 4:39:07 PM4/27/10
to col...@googlegroups.com
On Tue, Apr 27, 2010 at 1:30 PM, Coldwell, Scott <sc...@bugleme.com> wrote:
>
> On Mon, Apr 26, 2010 at 5:18 PM, Sean Corfield <seanco...@gmail.com>
> wrote:
>
>> Well, /index.cfm/test.cfm doesn't make sense as a URL.
>
> Isn't that the point of this discussion? I thought that the servlet mapping
> was to 'trick' tomcat into thinking that was a valid url?
>

The search engine friendly urls that the servlet mapping are designed
for are of the form /index.cfm/article/bob-the-builder which would
invoke index.cfm and then pass article and bob-the-builder as url
parameters to index.cfm. Your inclusion of test.cfm seems to be
telling the app server something like, "go find test.cfm and then pass
it to index.cfm", basically requesting two pages. The difference is
that in my example, it is not looking for any particular coldfusion
page besides index.cfm but rather sending the rest of the url request
in as a set of parameters.

Hope that clarifies things.

Judah

--
You received this message because you are subscribed to the Google Groups "ColdBox Platform" group.
To post to this group, send email to col...@googlegroups.com
To unsubscribe from this group, send email to coldbox-u...@googlegroups.com
For more options, visit this group at http://groups-beta.google.com/group/coldbox
For News, visit http://blog.coldbox.org
For Documentation, visit http://wiki.coldbox.org

Subscription settings: http://groups.google.com/group/coldbox/subscribe?hl=en

Sean Corfield

unread,
Apr 28, 2010, 4:24:08 PM4/28/10
to col...@googlegroups.com
On Tue, Apr 27, 2010 at 1:30 PM, Coldwell, Scott <sc...@bugleme.com> wrote:
>> Well, /index.cfm/test.cfm doesn't make sense as a URL.
>
> Isn't that the point of this discussion? I thought that the servlet mapping
> was to 'trick' tomcat into thinking that was a valid url?

Your URL has two filenames in it. It is not a sensible URL.

>         RewriteCond %{REQUEST_FILENAME} !-f
>         RewriteCond %{REQUEST_FILENAME} !-d
>         RewriteRule ^(.*)$ ajp://localhost:8009/index.cfm%{REQUEST_URI}
> [P,L] #this is the only modified line

This will rewrite /index.cfm/test.cfm to /index.cfm/index.cfm/test.cfm
which is probably not what you want.

Here's the RewriteRules that I use with ColdBox:

ProxyPreserveHost On
ProxyPassReverse / ajp://localhost:8009/

RewriteEngine On
# handle static assets without rewrite:
RewriteRule ^.*\.(bmp|gif|htc|jpe?g|ico|png|css|js|txt|pdf|doc|xls|xml)$ - [L]
# pass site root request thru directly:
RewriteRule ^/?$ ajp://localhost:8009/ [P,L]
# pass test and build requests thru directly:
RewriteRule ^/(core|mxunit|tests|railo-context)/(.*)$
ajp://localhost:8009/$1/$2 [P,L]
# pass all .cfm / .cfc requests thru:
RewriteRule ^/(.*\.cf[cm].*)$ ajp://localhost:8009/$1 [P,L]
# pass all others thru as assumed routes:
RewriteRule ^/(.*)$ ajp://localhost:8009/index.cfm/$1 [P,L]

Running thru the 5 rules:
1. Apache handles status assets
2. Pass default top-level URL direct to Tomcat (and ColdBox)
3. Pass certain directories thru unchanged (these are not ColdBox
apps, just regular CFML)
4. Pass any .cfm / .cfc requests thru unchanged
5. Prepend index.cfm to other requests and pass to Tomcat

With these rules, your URL is passed to ColdBox and the route is
/test.cfm (so ColdBox will fail to find a matching handler unless you
have an explicit route mapping /test.cfm to a ColdBox event).

Make sense?
--
Sean A Corfield -- (904) 302-SEAN
Railo Technologies, Inc. -- http://getrailo.com/
An Architect's View -- http://corfield.org/

"If you're not annoying somebody, you're not really alive."
-- Margaret Atwood

Coldwell, Scott

unread,
Apr 30, 2010, 4:05:22 PM4/30/10
to col...@googlegroups.com
Thanks, everyone, for your input. I wanted to let you know that I resolved the issue. The problem was that my servlet mapping pointed to the default servlet, not the CF servlet. I also had to move the servlet mapping to my WEB-INF/web.xml file instead of the tomcat/conf/web.xml

Thanks again.
Scott

CaptainPalapa

unread,
Nov 7, 2012, 6:33:20 PM11/7/12
to col...@googlegroups.com, seanco...@gmail.com
This helped me greatly.  Thank you for the post.

I am using the Railo4 Beta, with the latest Coldbox and ContentBox as of this writing, along with Apache 2.4.3.  Everything everwhere that I read said to use AJP like so:
<IfModule jk_module>
# Mod_jk settings
JkWorkersFile conf/workers.properties
JkMount /*.cfm default
JkLogFile "E:/Logs/Apache/mod_jk.log"
JkLogLevel error
</IfModule>

But combined with the rewrite rules packaged with Coldbox/Contentbox, they simply do not work.  Once I used your ruleset, I was able to move through much better!

Thanks for taking the time to put the info up.

- CP/WB
Reply all
Reply to author
Forward
0 new messages