Our Forums are now closed. Please go to our Google Mailing List for help. This site will remain open for historical purposes.
ColdBox Framework Forums Home | Profile | Search | Login | RSS

 pdf Print PDF   Previous Page  Page: 1   Next Page

Thread: SES routes.cfm on Apache
Created on: 01/21/08 12:21 PM Replies: 6
pwpeterson
Rookie

Joined: 06/11/07
Posts: 13
SES routes.cfm on Apache
01/21/08 12:21 PM

I hope somewhat can help me... I moved some CB apps to an apache/tomcat server and I am getting this message when I invoke them:

Error including config file: Could not find the included template /cfusion/[APPNAME]/config/routes.cfm.

This happens with the dashboard as well.

Any ideas why CF or CB can't find the routes.cfm file. It IS there...

pwp
Link | Top | Bottom
lmajano
Veteran Master

Joined: 01/29/05
Posts: 1209
RE: SES routes.cfm on Apache
01/21/08 1:09 PM

Try using an absolute path or just reinitializing the application.

I run my stuff on apache, but never have this problem. Its hard without seeing any of the code or your setup.
Luis Majano
Link | Top | Bottom
pwpeterson
Rookie

Joined: 06/11/07
Posts: 13
RE: SES routes.cfm on Apache
01/21/08 4:38 PM

I tried installing CF* last week and ran into some problem so I reinstalled CF7.

My Tomcat's appbase is C:\webapps. I just added a CF mapping of /cfusion => c:\webapps\cfusion and it started working again.

(Interesting my other CF apps worked fine before the mapping.)

I still can't start the cfadmin from CB's dashboard.


pwp
Link | Top | Bottom
Hayesdata


Joined: 06/11/09
Posts: 4
RE: SES routes.cfm on Apache
06/11/09 5:32 PM

I'm currently running into the same issue whilst working in Railo on Tomcat. I've tried every possible combination of mappings and xml config changes, however the issue seems to be with Tomcat.

Example URL:

http://localhost:8080/shoutEngine/index.cfm/users/login

What appears to be happening is that Tomcat is evaluating the entire path and not stopping at the index.cfm as it should.

If you have any ideas please let me know.
Link | Top | Bottom
lmajano
Veteran Master

Joined: 01/29/05
Posts: 1209
RE: SES routes.cfm on Apache
06/11/09 5:43 PM

Tomcat implements the servlet spec to the T. Therefore, url's like this:http://localhost:8080/shoutEngine/index.cfm/users/login are NOT allowed by the servlet specification.

Therefore, tomcat does not support them. You will have to run it through a rewrite filter or engine like mod_rewrite or j2ee rewrite filter to make them work like that.

I would suggest looking at mod rewrite or
https://simpleurlrewrite.dev.java.net/
or
http://tuckey.org/urlrewrite/
Luis Majano
Link | Top | Bottom
analogdigital
Veteran Master

Joined: 04/26/09
Posts: 121
RE: SES routes.cfm on Apache
07/01/09 3:05 AM

I have accomplished the following in ColdBox (notice no index.cfm):

http://foo.com/myHandler/action
http://foo.com/123
http://foo.com/user/25
http://foo.com/user/delete/28
etc...

Using three different methods. Tuckey UrlRewrite with Tomcat, mod_rewrite with Apache to Tomcat, as well as mod_jk from Apache to Tomcat. All three work identically when configured correctly. I have verified with extreme testing.

If you use mod_jk, the Tuckey UrlRewrite filter loaded in Tomcat as a servlet will do the rewrite without any rewrite rules needed in Apache:

<rule>
<from>^/index.cfm/(.*)$</from>
<to last="true">/index.cfm?PATH_INFO=$1</to>
</rule>

<rule>
<from>^/index.cfm</from>
<to last="true">/index.cfm</to>
</rule>

<rule>
<from>^/\?(.*)$</from>
<to last="true">/index.cfm?$1</to>
<set name="urlrewrite.originalRequestUri">%{request-uri}</set>
<set name="urlrewrite.originalQueryString">%{query-string}</set>
</rule>

<rule>
<from>^/(.*)$/\?(.*)</from>
<to last="true">/index.cfm?PATH_INFO=$1&amp;%{query-string}</to>
<set name="urlrewrite.originalRequestUri">%{request-uri}</set>
<set name="urlrewrite.originalQueryString">%{query-string}</set>
</rule>

<rule>
<from>^/(.*)$</from>
<to last="true">/index.cfm?PATH_INFO=$1&amp;%{query-string}</to>
<set name="urlrewrite.originalRequestUri">%{request-uri}</set>
<set name="urlrewrite.originalQueryString">%{query-string}</set>
</rule>

<rule>
<from>/(.*)$</from>
<to last="true">/index.cfm?PATH_INFO=$1</to>
<set name="urlrewrite.originalRequestUri">%{request-uri}</set>
<set name="urlrewrite.originalQueryString">%{query-string}</set>
</rule>

(I also have flex2gateway, etc, but it was too much to put here on the post)

If you use Tomcat standalone, the same rules for Tuckey UrlRewrite will work. The only difference is that Apache fowards its requests with jkMount but the rules are the same as far as Tomcat is concerned, it doesn't need Apache to have sent it the URL to rewrite it. If you access the Tomcat server directly with a URL, these rewrites will happen the same as if you came from Apache.

If you let Apache do the basic rewriting with mod_proxy, you can ProxyPass to Tomcat over AJP which will then allow UrlRewrite to do the more advanced rules (above)...

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

RewriteEngine On
RewriteRule ^/(.*\.cf[cm])$ ajp://localhost:8009/$1 [P]
RewriteRule ^/(.*)$ ajp://localhost:8009/$1 [P,L,R]


You can also do all of the rewriting in Apache and skip UrlFilter if you do this:

RewriteRule ^/(.*\.cf[cm])$ ajp://foo.com:8009/$1 [P]

RewriteRule ^/(.*\.cf[cm])(/.*)$ ajp://foo.com:8009/$1?path_info=$2&%{QUERY_STRING} [P]

RewriteRule ^/index.cfm ajp://foo.com:8009/index.cfm [P]

RewriteRule ^/(.*)$ ajp://foo.com:8009/$1?path_info=$1&%{QUERY_STRING} [P]


Instead of using the default SES interceptor, I simply created my own that extended the original and overwrote the preProcess() method. The reason I did this was because when you do this kind of rewriting, you lose CGI.PATH_INFO (which ColdBox uses for SES routes), so I passed it along as a URL variable. If you are using CF8 on IIS or not doing any rewriting, then you can just intercept with the normal SES interceptor.

I added this at the top of the method:

<cfif #isDefined("url.path_info")#>

<cfset MYPATH_INFO = "#url.path_info#">

<cfelse>

<cfset MYPATH_INFO = "">

</cfif>


Then replaced the normal cleanedPathInfo with this:

var cleanedPathInfo = #MYPATH_INFO#;
var cleanedScriptName = trim(reReplacenocase(getCGIElement('script_name'),"[/\\]index\.cfm",""));

This allows routes to use the PATH_INFO I passed over in the URL since it can't find the right value from the CGI scope.

This allows "perfect" URLs, since you can map routes to things like:

http://www.foo.com/username to:

pattern=":userID",
handler="users",
action="getUserProfile"
Link | Top | Bottom
Hayesdata


Joined: 06/11/09
Posts: 4
RE: SES routes.cfm on Apache
07/01/09 6:39 PM

Thanks analogdigital I'll try those filters out this evening.
Link | Top | Bottom

Galleon Forums V1.7.008 was created by Raymond Camden