CFM Pages Not Working After Server IP Change

BlueOnyx JSP and Servlets, including ColdFusion, CFM, CFML, Railo templates do not run after changing the IP address of the site and server. CFM displays as text.

Datacenter adjustments forced a change in IP addresses for my BlueOnyx server. The IP address of the server, and subsquently, the IP addresses of each of the sites within, had to be changed. Not a big issue, but then all of the CFM pages displayed as text. Not cool.

When the IP address was changed through the BlueOnyx Admin GUI, all of the vhosts were changed, inadvertantly dropping the JSP and Servlet switches. This can be added back either manually entering or through the GUI.

Option 1
Manually entering: find your SiteID for the site.

view plain print about
1basename $(ls -l /home/sites/| grep www.example.tld | awk '{ print $11}')

Then edit the vhosts file, using the correct SiteID

view plain print about
1vi /etc/httpd/conf/vhost/site1

adding back the JSP code:

view plain print about
1# BEGIN JSP SECTION. DO NOT EDIT MARKS OR IN BETWEEN.
2JkMount /* ajp13
3JkMount /*.jsp ajp13
4JkMount /servlet/* ajp13
5# END JSP SECTION. DO NOT EDIT MARKS OR IN BETWEEN.

Then restart httpd:

view plain print about
1/etc/init.d/httpd restart

Now you should be serving up those fancy CFM pages.

Option 2
Through the GUI, in the Web settings for the site, uncheck Enable JSP and Servlets and save. When it finishes saving and resetting, recheck or enable Enable JSP and Servlets and save. This will add 2 lines of the above code block, but you still need to add this to run CFML.

view plain print about
1JkMount /* ajp13

So you still have to edit vhosts (SiteID!)

view plain print about
1vi /etc/httpd/conf/vhost/site1

Change the JSP section from this:

view plain print about
1# BEGIN JSP SECTION. DO NOT EDIT MARKS OR IN BETWEEN.
2JkMount /*.jsp ajp13
3JkMount /servlet/* ajp13
4# END JSP SECTION. DO NOT EDIT MARKS OR IN BETWEEN.
to this:
view plain print about
1# BEGIN JSP SECTION. DO NOT EDIT MARKS OR IN BETWEEN.
2JkMount /* ajp13
3JkMount /*.jsp ajp13
4JkMount /servlet/* ajp13
5# END JSP SECTION. DO NOT EDIT MARKS OR IN BETWEEN.

Then restart httpd:

view plain print about
1/etc/init.d/httpd restart

Back in business, running your fantastice CFML site!

Mura on Railo and BlueOnyx

Once Railo is installed and configured on BlueOnyx, make sure you have a MySQL database created and have all the connection info, like username, database name, user password. Create the datasource in Railo Admin.

Download Mura Standard from www.getmura.com/download/mura-downloads/ to your local machine. Unzip or extract the .ZIP file. FTP all files up to your sites /web/ directory. I deleted everything in the /web/ folder EXCEPT /WEB-INF/. These files were created with the Railo install and left from the BO initial site creation.

In your browser, go to http:///index.cfm

I received this error:

Railo 3.3.1.000 Error (application) Message can't copy file [/home/.sites/33/site22/web/config/templates/settings.template.cfm] to [/home/.sites/33/site22/web/config/settings.ini.cfm] Detail Permission denied Stacktrace The Error Occurred in /home/.sites/33/site22/web/config/applicationSettings.cfm: line 88 86: 87: 88: 89: 90: called from/home/.sites/33/site22/web/Application.cfc: line 48 46: ---> 47: 48: 49: 50: We need to add Tomcat to the site's group and change permissions to write for the group on the /web/config/ directory and contents.

We need to adjust permissions

view plain print about
1vi /etc/group
find your site's group, e.g., site22 add tomcat to the group, similar to:
view plain print about
1site22:x:599:johnny,admin,billy,tomcat

Then recursively add write permissions for the /web/config/ directory. Once you are in the /web/ directory.

view plain print about
1chmod -R g+w config

This will allow site members to FTP files.

This will fix the permission denied for the config stuff

view plain print about
1chmod o+w config
But we probably didn't have to do that if we do this....

Navigate up a level and change ownership of /web/ to tomcat.

view plain print about
1cd ../
2chown tomcat.site22 web

Next to run the SEO URL query strings for Mura, you'll have to modify the /web/WEB-INF/web.xml file to allow the wildcards:

view plain print about
1vi /web/WEB-INF/web.xml

add the following lines:

view plain print about
1��<servlet-mapping>
2� ��<servlet-name>CFMLServlet</servlet-name>
3� ��<url-pattern>/index.cfm/*</url-pattern>
4��</servlet-mapping>
in with the rest of the servlet-mappings.

Restart tomcat.

view plain print about
1/sbin/service tomcat5 restart

You should be able to run your Mura site without issue. If you do, please comment here and I'll look into it.

Railo Tuckey UrlRewrite Application - Part 2

Continuation of http://www.cfjoe.com/index.cfm/2011/4/26/Railo-Tuckey-UrlRewrite-Application--Part-1

We'll take things a bit further here by turning our previous effort into a real CFML application with form submission.

This application:

  1. reads and presents the current urlrewrite.xml
  2. queries the "redirect" table
  3. outputs (dumps) the new urlrewrite.xml without overwriting the existing
  4. gives the user the option of writing the new urlrewrite.xml for either production or staging
Selecting one or the other then:
  1. Reads the current urlrewrite.xml
  2. Writes a backup of the current urlrewrite.xml
  3. Queries the database for desired 301 redirects
    1. Creates xml
    2. With rules
  4. Looping and outputting 301 query
  5. writes the new urlrewrite.xml
  6. reads it again and dumps for our viewing pleasure.

As we do not want to restart Railo each time we update urlrewrite.xml, we take advantage of the confReloadCheckInterval parameter in web.xml. See this blog entry for more info.

Why not format the xml using the XmlFormat() tag? I did try this and it took too long to parse and render. It was much quicker, and quite frankly, easier to read the string text output, using the ToString(xml) tag.

Here's the full code:

view plain print about
1<!--- ulrewritexml.cfm --->
2<!--- This app creates the xml file used for assigned 301 redirects --->
3<!--- writes urlrewrite.xml used by Tuckey rewrite filter in Tomcat --->
4
5<cfset variables.datasourcename="MyDatabase" >
6<!--- FORM PROCESSING --->
7
8<!--- we are updating 2 sites, staging and production --->
9<cfif StructKeyExists(form,"whichserver")>
10    <cfif form.whichserver EQ "staging">
11        <cfset variables.xmlfilepath="/opt/railo/tomcat/webapps/ROOT/staging.cfjoe.com/WEB-INF/urlrewrite.xml">
12        <!--- turn the rules off for staging --->
13        <cfset variables.ruleenable="false">
14    <cfelseif form.whichserver EQ "production">
15        <cfset variables.xmlfilepath="/opt/railo/tomcat/webapps/ROOT/www.cfjoe.com/WEB-INF/urlrewrite.xml">
16        <!--- turn on the rules for production - security! --->
17        <cfset variables.ruleenable="true">
18    </cfif>
19    
20<!--- read the current urlrewrite.xml --->
21<cffile action="read"
22        file="#xmlfilepath#"
23        variable="urlrewritexml">

24        
25<!--- make the back up and save --->
26<cffile action="write"
27        file="#xmlfilepath#.#DateFormat(Now(),"yyyymmdd")#-#TimeFormat(Now(),"HHmm")#"
28        fixnewline="yes"
29        output="#urlrewritexml#">

30
31<!--- What? How do we do this? confReloadCheckInterval param in web.xml. No Railo restart required! --->        
32<p>Your changes have been completed and will take 60 seconds to take affect on the web server. You may compare the old and new XML document objects below:</p>
33<p>The old urlrewrite.xml</p>        
34<cfdump var="#ToString(urlrewritexml)#">
35
36<!--- make the new xml from database --->
37<cfquery name="q301" datasource="#datasourcename#">
38 SELECT    RedirectID, OldPath, NewPath
39     FROM        redirect
40</cfquery>
41
42<cfxml variable="urlrewrite2xml">
43<?xml version="1.0" encoding="utf-8"?>
44<!DOCTYPE urlrewrite PUBLIC "-//tuckey.org//DTD UrlRewrite 3.2//EN"
45 "http://tuckey.org/res/dtds/urlrewrite3.2.dtd">

46
47<!--
48
49 Configuration file for UrlRewriteFilter
50 http://tuckey.org/urlrewrite/
51
52-->

53<urlrewrite>
54
55 <rule>
56 <note>
57 The rule means that requests to /test/status/ will be redirected to /rewrite-status
58 the url will be rewritten.
59 </note>
60 <from>/test/status/</from>
61 <to type="redirect">%{context-path}/rewrite-status</to>
62 </rule>
63    
64 <!-- disable Railo Admin -->
65 <rule enabled="<cfoutput>#ruleenable#</cfoutput>">
66 <name>Disable Railo</name>
67 <from>^/railo-context/admin/(.*)$</from>
68 <to>null</to>
69 <set type="status">403</set>
70 </rule>
71    
72 <!-- disable Mura Admin -->
73 <rule enabled="<cfoutput>#ruleenable#</cfoutput>">
74 <name>Disable Mura</name>
75 <from>^/admin/(.*)$</from>
76 <to>null</to>
77 <set type="status">403</set>
78 </rule>
79    
80 <!-- disable WebAdmin directory -->
81 <rule enabled="<cfoutput>#ruleenable#</cfoutput>">
82 <name>Disable WebAdmin</name>
83 <from>^/WebAdmin/(.*)$</from>
84 <to>null</to>
85 <set type="status">403</set>
86 </rule>
87
88 <!-- 301 redirects from urlrewrite app -->
89    <cfoutput query="q301">
90 <rule>
91 <from>#OldPath#</from>
92 <to type="permanent-redirect">#NewPath#</to>
93 </rule>
94    </cfoutput>
95
96 <outbound-rule>
97 <note>
98 The outbound-rule specifies that when response.encodeURL is called (if you are using JSTL c:url)
99 the url /rewrite-status will be rewritten to /test/status/.
100
101 The above rule and this outbound-rule means that end users should never see the
102 url /rewrite-status only /test/status/ both in thier location bar and in hyperlinks
103 in your pages.
104 </note>
105 <from>/rewrite-status</from>
106 <to>/test/status/</to>
107 </outbound-rule>
108
109</urlrewrite>    
110</cfxml>
111<cfset newurlrewritexml = ToString(urlrewrite2xml)>
112
113<!--- write the new urlrewrite.xml --->
114<cffile action="write"
115        file="#xmlfilepath#"
116        fixnewline="yes"
117        output="#newurlrewritexml#">

118
119<!--- read the new one --->        
120<cffile action="read"
121        file="#xmlfilepath#"
122        variable="viewurlrewritexml">

123<p>The new urlrewrite.xml</p>        
124<cfdump var="#ToString(viewurlrewritexml)#">
125
126<!--- SHOW FORM --->
127<cfelse>
128<p>This is the current urlrewrite.xml. The publish button is at the bottom.</p>
129
130<!--- read the current urlrewrite.xml --->
131<cffile action="read"
132        file="/opt/railo/tomcat/webapps/ROOT/staging.cfjoe.com/WEB-INF/urlrewrite.xml"
133        variable="urlrewritexml">

134        
135<cfdump var="#ToString(urlrewritexml)#">
136
137<!--- make the new xml from database --->
138<cfquery name="q301" datasource="#datasourcename#">
139 SELECT    RedirectID, OldPath, NewPath
140     FROM        redirect
141</cfquery>
142
143<cfxml variable="urlrewrite2xml">
144<?xml version="1.0" encoding="utf-8"?>
145<!DOCTYPE urlrewrite PUBLIC "-//tuckey.org//DTD UrlRewrite 3.2//EN"
146 "http://tuckey.org/res/dtds/urlrewrite3.2.dtd">

147
148<!--
149
150 Configuration file for UrlRewriteFilter
151 http://tuckey.org/urlrewrite/
152
153-->

154<urlrewrite>
155
156 <rule>
157 <note>
158 The rule means that requests to /test/status/ will be redirected to /rewrite-status
159 the url will be rewritten.
160 </note>
161 <from>/test/status/</from>
162 <to type="redirect">%{context-path}/rewrite-status</to>
163 </rule>
164    
165 <!-- disable Railo Admin -->
166 <rule enabled="false">
167 <name>Disable Railo</name>
168 <from>^/railo-context/admin/(.*)$</from>
169 <to>null</to>
170 <set type="status">403</set>
171 </rule>
172    
173 <!-- disable Mura Admin -->
174 <rule enabled="false">
175 <name>Disable Mura</name>
176 <from>^/admin/(.*)$</from>
177 <to>null</to>
178 <set type="status">403</set>
179 </rule>
180    
181 <!-- disable WebAdmin directory -->
182 <rule enabled="false">
183 <name>Disable WebAdmin</name>
184 <from>^/WebAdmin/(.*)$</from>
185 <to>null</to>
186 <set type="status">403</set>
187 </rule>
188    
189    <!-- 301 redirects from urlrewrite app -->
190    <cfoutput query="q301">
191 <rule>
192 <from>#OldPath#</from>
193 <to type="permanent-redirect">#NewPath#</to>
194 </rule>
195    </cfoutput>
196
197 <outbound-rule>
198 <note>
199 The outbound-rule specifies that when response.encodeURL is called (if you are using JSTL c:url)
200 the url /rewrite-status will be rewritten to /test/status/.
201
202 The above rule and this outbound-rule means that end users should never see the
203 url /rewrite-status only /test/status/ both in thier location bar and in hyperlinks
204 in your pages.
205 </note>
206 <from>/rewrite-status</from>
207 <to>/test/status/</to>
208 </outbound-rule>
209
210</urlrewrite>    
211</cfxml>
212<cfset newurlrewritexml = ToString(urlrewrite2xml)>
213
214<p>This would be the new urlrewrite.xml</p>        
215<cfdump var="#ToString(newurlrewritexml)#">
216
217<p>
218<form name="urlrewritexml-staging" action="urlrewritexml.cfm" method="post">
219    <input type="hidden" name="whichserver" value="staging">
220    <input type="submit" name="submit" value="Publish to Staging">
221</form>
222</p>
223
224<p>
225<form name="urlrewritexml-production" action="urlrewritexml.cfm" method="post">
226    <input type="hidden" name="whichserver" value="production">
227    <input type="submit" name="submit" value="Publish to Production">
228</form>
229</p>
230
231
232</cfif>

Railo Tuckey UrlRewrite Application - Part 1

Railo, Tomcat, Tuckey URL Rewrite filter and 301 redirects read from a database using ColdFusion or CFML.

Instead of constantly rewriting the urlrewrite.xml file with vi or nano directly on the server, we built a small ColdFusion/Railo/CFML application to easily edit our 301 redirects.

The admin side, which will not be shown here and is easy to duplicate, allows the user to add pages which will 301 redirect. They simply enter the old URL and the new URL. The table, titled redirect, has 3 columns, RedirectID, OldPath, NewPath. For example, the user wishes /my/old/page.cfm to go to my/new/directory/page.cfm with a 301 status code, and thus, would enter

What this application does:

  1. Reads the current urlrewrite.xml using cffile
  2. Writes a backup of the current urlrewrite.xml with cffile
  3. Queries the database for desired 301 redirects
    1. Creates xml
    2. With rules
  4. Looping and outputting 301 query
  5. writes the new urlrewrite.xml
  6. reads it again and dumps for our viewing pleasure.

We take advantage of the rules filter which turns on and off access to private directories like Railo and Mura admin per this blog entry.

Here's the code:

view plain print about
1<!--- ulrewritexml.cfm --->
2<!--- This app creates the xml file used for assigned 301 redirects --->
3<!--- writes urlrewrite.xml used by Tuckey rewrite filter in Tomcat --->
4
5<cfset variables.datasourcename="MyDatabase" >
6
7<!--- set file path of urlrewrite.xml --->
8<cfset variables.xmlfilepath="/opt/railo/tomcat/webapps/ROOT/cfjoe.com/WEB-INF/urlrewrite.xml">
9
10<!--- set on/off for rules - see the xml for rules --->
11<!--- we use this to disable public access to private directories --->
12<cfset variables.ruleenable="true">
13
14    
15<!--- read the current urlrewrite.xml --->
16<cffile action="read"
17        file="#xmlfilepath#"
18        variable="urlrewritexml">

19        
20<!--- make the back up and save --->
21<cffile action="write"
22        file="#xmlfilepath#.#DateFormat(Now(),"yyyymmdd")#-#TimeFormat(Now(),"HHmm")#"
23        fixnewline="yes"
24        output="#urlrewritexml#">

25        
26<!--- make the new xml from database --->
27<cfquery name="q301" datasource="#datasourcename#">
28 SELECT    RedirectID, OldPath, NewPath
29     FROM        redirect
30</cfquery>
31
32<cfxml variable="urlrewrite2xml">
33<?xml version="1.0" encoding="utf-8"?>
34<!DOCTYPE urlrewrite PUBLIC "-//tuckey.org//DTD UrlRewrite 3.2//EN"
35 "http://tuckey.org/res/dtds/urlrewrite3.2.dtd">

36
37<!--
38
39 Configuration file for UrlRewriteFilter
40 http://tuckey.org/urlrewrite/
41
42-->

43<urlrewrite>
44
45 <rule>
46 <note>
47 The rule means that requests to /test/status/ will be redirected to /rewrite-status
48 the url will be rewritten.
49 </note>
50 <from>/test/status/</from>
51 <to type="redirect">%{context-path}/rewrite-status</to>
52 </rule>
53    
54    <!--- here are the rules! --->
55 <!-- disable Railo Admin -->
56 <rule enabled="<cfoutput>#ruleenable#</cfoutput>">
57 <name>Disable Railo</name>
58 <from>^/railo-context/admin/(.*)$</from>
59 <to>null</to>
60 <set type="status">403</set>
61 </rule>
62    
63 <!-- disable Mura Admin -->
64 <rule enabled="<cfoutput>#ruleenable#</cfoutput>">
65 <name>Disable Mura</name>
66 <from>^/admin/(.*)$</from>
67 <to>null</to>
68 <set type="status">403</set>
69 </rule>
70    
71 <!-- disable WebAdmin directory -->
72 <rule enabled="<cfoutput>#ruleenable#</cfoutput>">
73 <name>Disable WebAdmin</name>
74 <from>^/WebAdmin/(.*)$</from>
75 <to>null</to>
76 <set type="status">403</set>
77 </rule>
78
79 <!-- 301 redirects from urlrewrite app -->
80    <cfoutput query="q301">
81 <rule>
82 <from>#OldPath#</from>
83 <to type="permanent-redirect">#NewPath#</to>
84 </rule>
85    </cfoutput>
86
87 <outbound-rule>
88 <note>
89 The outbound-rule specifies that when response.encodeURL is called (if you are using JSTL c:url)
90 the url /rewrite-status will be rewritten to /test/status/.
91
92 The above rule and this outbound-rule means that end users should never see the
93 url /rewrite-status only /test/status/ both in thier location bar and in hyperlinks
94 in your pages.
95 </note>
96 <from>/rewrite-status</from>
97 <to>/test/status/</to>
98 </outbound-rule>
99
100</urlrewrite>    
101</cfxml>
102<cfset newurlrewritexml = ToString(urlrewrite2xml)>
103
104<!--- write the new urlrewrite.xml --->
105<cffile action="write"
106        file="#xmlfilepath#"
107        fixnewline="yes"
108        output="#newurlrewritexml#">

109
110<!--- read the new one --->        
111<cffile action="read"
112        file="#xmlfilepath#"
113        variable="viewurlrewritexml">

114
115<!--- lets look at it --->
116<p>The new urlrewrite.xml</p>        
117<cfdump var="#ToString(viewurlrewritexml)#">

Tuckey urlrewrite 301 redirects

Setting the <set> attribute with type=status to 301 as many examples show is NOT the right way to set your HTTP Headers status.
This is incorrect!

view plain print about
1<rule>
2 <from>OldPath</from>
3 <to type="redirect">NewPath</to>
4 <set type="status">301</set>
5 </rule>

The type attribute for HTTP Header status is placed within the <to> element. From the Tuckey URL Rewrite Filter manual

Attribute Possible Value Explanation
type
(optional)
forward (default) Requests matching the "conditions" for this "rule", and the URL in the "from" element will be internally forwarded to the URL specified in the "to" element. Note: In this case the "to" URL must be in the same context as UrlRewriteFilter. This is the same as doing:
RequestDispatcher rq = request.getRequestDispatcher([to value]);
rq.forward(request, response);
passthrough Identical to "forward".
redirect Requests matching the "conditions" and the "from" for this rule will be HTTP redirected. This is the same a doing:
HttpServletResponse.sendRedirect([to value]))
permanent-redirect The same as doing:
response.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY);
response.setHeader("Location", [to value]);
(note, SC_MOVED_TEMPORARILY is HTTP status code 301)
temporary-redirect The same as doing:
response.setStatus(HttpServletResponse.SC_MOVED_TEMPORARILY);
response.setHeader("Location", [to value]);
(note, SC_MOVED_TEMPORARILY is HTTP status code 302)
last
(optional)
false (default) The rest of the "rules" will be processed if this one succeeds.
true No more "rules" will be processed if this one is a match.
encode
(optional)
false (default if under rule) response.encodeURL([to]) will be run on the to url before performing the rewrite.
true (default if under outbound-rule) response.encodeURL([to]) will NOT be called.

This is what is should be for a 301 redirect:

view plain print about
1<rule>
2 <from>OldPath</from>
3 <to type="permanent-redirect">NewPath</to>
4 </rule>

SES URLs with Mura, Railo, Tomcat, Ubuntu

SES URLs with Mura, Railo, Tomcat, Ubuntu

It can't be done without URL Rewrite Filter from http://www.tuckey.org/urlrewrite/ .

Though I could easily wget the zip file to my Ubuntu server, Unzip is not installed, therefore, and I was unsuccessful trying to gunzip or gzip –d the zip file. I didn't want to get started downloading every little thing available whenever it was needed so I chose to download to my PC and FTP to a directory my FTP account could access. I chose the binaries zip file from http://www.tuckey.org/urlrewrite/ , unzipped into my PC, and FTP'ed up to the server.

Once on the server move the lib to my tomcat/lib directory

view plain print about
1admin@railo:/opt/railo/tomcat$ sudo mv webapps/ROOT/mysite.com/mysite/assets/urlrewrite-3.2.0.jar lib/
2admin@railo:/opt/railo/tomcat$ ls -la lib/
3total 5224
4drwxr-xr-x 2 railo railo 4096 2011-01-26 14:20 .
5drwxr-xr-x 9 railo railo 4096 2011-01-04 12:14 ..
6-rw-r--r-- 1 railo railo 15240 2010-12-17 16:37 annotations-api.jar
7-rw-r--r-- 1 railo railo 53752 2010-12-17 16:37 catalina-ant.jar
8-rw-r--r-- 1 railo railo 129627 2010-12-17 16:37 catalina-ha.jar
9-rw-r--r-- 1 railo railo 1191060 2010-12-17 16:37 catalina.jar
10-rw-r--r-- 1 railo railo 235004 2010-12-17 16:37 catalina-tribes.jar
11-rw-r--r-- 1 railo railo 32384 2010-12-17 16:37 el-api.jar
12-rw-r--r-- 1 railo railo 108570 2010-12-17 16:37 jasper-el.jar
13-rw-r--r-- 1 railo railo 525001 2010-12-17 16:37 jasper.jar
14-rw-r--r-- 1 railo railo 1407902 2010-12-17 16:37 jasper-jdt.jar
15-rw-r--r-- 1 railo railo 76693 2010-12-17 16:37 jsp-api.jar
16-rw-r--r-- 1 railo railo 88224 2010-12-17 16:37 servlet-api.jar
17-rw-r--r-- 1 railo railo 758137 2010-12-17 16:37 tomcat-coyote.jar
18-rw-r--r-- 1 railo railo 249650 2010-12-17 16:37 tomcat-dbcp.jar
19-rw-r--r-- 1 railo railo 70035 2010-12-17 16:37 tomcat-i18n-es.jar
20-rw-r--r-- 1 railo railo 51966 2010-12-17 16:37 tomcat-i18n-fr.jar
21-rw-r--r-- 1 railo railo 55037 2010-12-17 16:37 tomcat-i18n-ja.jar
22-rw-r--r-- 1 admin admin 198436 2011-01-26 14:17 urlrewrite-3.2.0.jar

Then change group and ownership to railo:

view plain print about
1admin@railo:/opt/railo/tomcat$ sudo chown railo.railo lib/urlrewrite-3.2.0.jar
2admin@railo:/opt/railo/tomcat$ ls -la lib/
3total 5224
4drwxr-xr-x 2 railo railo 4096 2011-01-26 14:20 .
5drwxr-xr-x 9 railo railo 4096 2011-01-04 12:14 ..
6-rw-r--r-- 1 railo railo 15240 2010-12-17 16:37 annotations-api.jar
7-rw-r--r-- 1 railo railo 53752 2010-12-17 16:37 catalina-ant.jar
8-rw-r--r-- 1 railo railo 129627 2010-12-17 16:37 catalina-ha.jar
9-rw-r--r-- 1 railo railo 1191060 2010-12-17 16:37 catalina.jar
10-rw-r--r-- 1 railo railo 235004 2010-12-17 16:37 catalina-tribes.jar
11-rw-r--r-- 1 railo railo 32384 2010-12-17 16:37 el-api.jar
12-rw-r--r-- 1 railo railo 108570 2010-12-17 16:37 jasper-el.jar
13-rw-r--r-- 1 railo railo 525001 2010-12-17 16:37 jasper.jar
14-rw-r--r-- 1 railo railo 1407902 2010-12-17 16:37 jasper-jdt.jar
15-rw-r--r-- 1 railo railo 76693 2010-12-17 16:37 jsp-api.jar
16-rw-r--r-- 1 railo railo 88224 2010-12-17 16:37 servlet-api.jar
17-rw-r--r-- 1 railo railo 758137 2010-12-17 16:37 tomcat-coyote.jar
18-rw-r--r-- 1 railo railo 249650 2010-12-17 16:37 tomcat-dbcp.jar
19-rw-r--r-- 1 railo railo 70035 2010-12-17 16:37 tomcat-i18n-es.jar
20-rw-r--r-- 1 railo railo 51966 2010-12-17 16:37 tomcat-i18n-fr.jar
21-rw-r--r-- 1 railo railo 55037 2010-12-17 16:37 tomcat-i18n-ja.jar
22-rw-r--r-- 1 railo railo 198436 2011-01-26 14:17 urlrewrite-3.2.0.jar

Now move the ulrewrite.xml to the appropriate WEB-INF directory:

view plain print about
1admin@railo:/opt/railo/tomcat$ sudo mv webapps/ROOT/mysite.com/mysite/assets/urlrewrite.xml webapps/ROOT/WEB-INF/

Don't forget to change ownership:

view plain print about
1admin@railo:/opt/railo/tomcat$ sudo chown railo.railo webapps/ROOT/WEB-INF/urlrewrite.xml

Now you can follow these very clear instructions from Adam Presley and Steve Good.

http://blog.adampresley.com/2010/ses-urls-with-mura-on-tomcat/
http://stevegood.org/blog/rewriting-urls-with-railo-resin-for-mura-cms/

But there are some differences....

My /opt/railo/tomcat/webapps/ROOT/WEB-INF/web.xml contained only:

view plain print about
1<web-app xmlns="http://java.sun.com/xml/ns/javaee"
2 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3 xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
4 version="2.5">

5
6 <display-name>Welcome to Tomcat</display-name>
7 <description>
8 Welcome to Tomcat
9 </description>
10</web-app>

So I added this right after the <description> tag

view plain print about
1<!-- URL Rewrite Filter -->
2 <filter>
3 <filter-name>UrlRewriteFilter</filter-name>
4 <filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class>
5 <init-param>
6 <param-name>logLevel</param-name>
7 <param-value>WARN</param-value>
8 </init-param>
9 </filter>
10 <filter-mapping>
11 <filter-name>UrlRewriteFilter</filter-name>
12 <servlet-name>CFMLServlet</servlet-name>
13 </filter-mapping>
14
15 <!-- SES URL pattern -->
16 <servlet-mapping>
17 <servlet-name>CFMLServlet</servlet-name>
18 <url-pattern>/index.cfm/*</url-pattern>
19 </servlet-mapping>

There is a /opt/railo/tomcat/conf/web.xml which contains all the mappings and all the other servlet-mappings.

In urlrewrite.xml in the same /WEB-INF/ folder this was added under the /test/status/ rule

view plain print about
1<rule>
2        <note>
3            Makes all requests forward to /index.cfm/whatever-came-next
4            Ignores admin URLs so the admin still works correctly for Mura.
5        </note>
6        <from>^/(?!admin|plugins|js|css|assets|images|tasks|railo-context|flex2gateway|wysiwyg)(.*)$</from>
7        <to>/index.cfm/$1</to>
8    </rule>

Railo Tomcat Custom 404

How do I add a custom 404 error page for Railo Tomcat?

In your {Railo Tomcat}/conf/web.xml, mine, on Ubuntu is /opt/railo/tomcat/conf/web.xml, down at the very bottom under the welcome-file-list add this:

view plain print about
1snipped
2.....
3 </welcome-file-list>
4
5 <error-page>
6 <error-code>404</error-code>
7 <location>/MyErrorDir/MyCustom404.cfm</location>
8 </error-page>

The path to your custom 404 CFM template should be relative to your site's root. If you have multiple sites, each should have the same path.

Railo Tomcat 404 redirects and CGI vars

I've run into an issue with 404 redirects on Ubuntu - Railo - Tomcat (no Apache).

I have the site's /WEB-INF/web.xml redirecting 404 errors to a custom 404.cfm which tries to read and act on certain CGI variables. The problem is that I'm not getting all the CGI variables, most are null. The QUERY_STRING is the only variable passed from the missing template. The rest are either null or for the 404.cfm.

What I want is the template path and query string of the missing template.

Here are some of the cfdumps I've tried:

view plain print about
1<cfdump var="#cgi#">
2<cfdump var="#getPageContext().getRequest()#"><!--- returns HTTPServletRequestWrap class, fields, methods --->
3<cfdump var="#getPageContext().getRequest().getOriginalRequest()#"><!--- returns ApplicationHttpRequest class, fields, methods --->
4<cfdump var="#getPageContext().getRequest().getOriginalRequest().getAttributeNames()#"><!--- returns apparently useable strings --->
5<cfdump var="#getPageContext().getRequest().getOriginalRequest().getAttribute("query_string")#"><!--- returns Empty:null --->
6<cfdump var="#getPageContext().getRequest().getOriginalRequest().getParameterNames()#"><!--- returns "id" --->
7<cfdump var="#getPageContext().getRequest().getOriginalRequest().getHeaderNames()#"><!--- returns apparently useable strings --->
8<cfdump var="#getPageContext().getRequest().getOriginalRequest().getQueryString()#"><!--- returns original template's query string Yay! --->
9<cfdump var="#getPageContext().getRequest().getOriginalRequest().getRequestURL()#"><!--- returns URL for 404.cfm --->
10<cfdump var="#getPageContext().getRequest().getOriginalRequest().getAttribute("Referer")#"><!--- returns Empty:null --->
11<cfdump var="#getPageContext().getRequest().getOriginalRequest().getAttribute("Redirect_URL")#"><!--- returns Empty:null --->

Any ideas would be GREATLY appreciated. Remember, Tomcat is the web server without Apache.

SES URLs With Mura on Tomcat

I did not write this blog post. I copied directly from Adam Presley's Blog. I copied this purely for convenience and ease of multiple reference within this site. Thank you Adam!

and so Adam says...

Tonight as I'm setting up a new server I wanted to make sure I had URL rewrite ability. Normally this is no issue as I use Apache for most anything web server related. However this time I am setting up a Mura site on Railo running on Tomcat. And yes, I'm using Tomcat for both my Java Servlet engine and my web server. As such I wanted to ensure I have "pretty URLs" for my Mura-based application. In this post I will attempt to show you how to set that up.

At this point I am going to assume you have a running Tomcat and Mura application. The first thing we need to do is download Paul Tuckey's excellent UrlRewriteFilter Java filter. This can be located at http://www.tuckey.org/urlrewrite/. The version I downloaded as of this writing is 3.2.0. Once downloaded you can extract the contents anywhere you wish to keep it. You will notice there isn't much there... in fact at the top level there is only a folder named WEB-INF. Opening that folder doesn't reveal much more.

If you have Tomcat running you'll need to stop it temporarily for this next part. After stopping Tomcat, copy the file /WEB-INF/lib/urlrewrite-3.2.0.jar into your lib folder, found at {TOMCAT}/lib, where {TOMCAT} is the folder where you have placed your Tomcat installation. By copying this JAR file there you are making the URL re-writer filter available to all Java applications running in your Tomcat instance.

The next phase is to setup Railo (yes, you can do this in Adobe CF as well) to use this Java re-writer filter. Where you do this varies based on how you have setup your Railo application, but I have my Railo files extracted in my Mura application's web root directory. So in my main Mura directory I have a WEB-INF folder containing the entire Railo library.

If you open up that WEB-INF folder there should be a web.xml file. Open this file in your favorite text editor. Near the top, after the <display-name> node and before the <servlet> nodes paste the following XML.

view plain print about
1<!-- URL Rewrite Filter -->
2    <filter>
3        <filter-name>UrlRewriteFilter</filter-name>
4        <filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class>
5        <init-param>
6             <param-name>logLevel</param-name>
7             <param-value>WARN</param-value>
8        </init-param>
9    </filter>
10    <filter-mapping>
11        <filter-name>UrlRewriteFilter</filter-name>
12        <servlet-name>CFMLServlet</servlet-name>
13    </filter-mapping>

This block of XML tells Tomcat, when loading your application, to install this URL re-write filter, and to map any requests that come through the CFMLServlet to it. Basically that means that any CFM or CFC requests will go through the filter.

The next part of this same file that must be altered is the servlet mappings to allow paths after "index.cfm". This allows Mura to execute requests like "/index.cfm/contact-us/". To do this find the following block of XML:

view plain print about
1<servlet-mapping>
2        <servlet-name>CFMLServlet</servlet-name>
3        <url-pattern>*.cfm</url-pattern>
4    </servlet-mapping>

Once you find this, you want to insert this next block of XML right after it.

view plain print about
1<servlet-mapping>
2        <servlet-name>CFMLServlet</servlet-name>
3        <url-pattern>/index.cfm/*</url-pattern>
4    </servlet-mapping>

Now we are ready to configure the re-writer filter to forward our "pretty" SES URLs to index.cfm! In the extracted files there is a file named urlrewrite.xml. Copy this file into the same folder as your Railo web.xml file that we just got done modifying. Now open it up. Fortunately this file is pretty well documented, and the online docs have even more information! For the moment, though, we just want to make sure that all of our SES URLs go to the right place. The other concern here is to also ensure that when we go to Mura's administrator, the URLs DO NOT get forwarded to index.cfm. So, with a little bit of regular expression magic, we can make UrlRewriteFilter do this.

view plain print about
1<?xml version="1.0" encoding="utf-8"?>
2<!DOCTYPE urlrewrite PUBLIC "-//tuckey.org//DTD UrlRewrite 3.2//EN" "http://tuckey.org/res/dtds/urlrewrite3.2.dtd">
3
4<!--
5
6 Configuration file for UrlRewriteFilter
7 http://tuckey.org/urlrewrite/
8
9-->

10<urlrewrite>
11    <rule>
12        <note>
13            Makes all requests forward to /index.cfm/whatever-came-next
14            Ignores admin URLs so the admin still works correctly for Mura.
15        </note>
16        <from>^/(?!admin|plugins|js|css|assets|images|tasks|railo-context|flex2gateway|wysiwyg)(.*)$</from>
17        <to>/index.cfm/$1</to>
18    </rule>
19</urlrewrite>

Ok, super. The final phase is to tell Mura that we wish to make our URL's pretty! To do this, start Tomcat back up, then log into your Mura administrator and browse to File Manager -> Application Root and click on the folder config. In this folder there is a file named settings.ini.cfm. Click on the pencil icon to the right of the file name to edit it. Once inside we are looking for two settings: siteidinurls and indexfileinurls. These settings should both be set to zero (0). Once you save those changes make sure to click on Reload Application.

And with that you should be able to browse to your Mura site without the crazy question marks or index.cfm in the URL. But if you are in the administrator you should still have all the question marks so it behaves as expected.

I hope this helped somebody out there. Cheers, and happy coding!

How to Set Up Mura Staging and Production Sites

The client/customer/company wants a separate Staging and Production server. They are not interested in using Mura's preview, draft and publish functionality.

The site is running:
Mura
-Core Version 5.3.3088
-Site Version 5.3.2831
Railo 3.2.1.000 final
Ubuntu 10.04.1 LTS 32 bit

Fortunately, setting up a staging and production server in Mura cannot be easier. There are a few things you should know first though.

  1. Your staging and production server have to be on the same machine.
  2. If it's a VM, virtual machine, the servers will both have to be within the same VM.
  3. You will need to put your production site's datasource in your Railo/CF engine's site.

Follow these directions straight off of Mura's site
http://docs.getmura.com/index.cfm/installation-set-up/staging-to-production-deployment/

Instance Deployment

  1. Install an instance of Mura on each server
  2. Make sure you have site(s) in each install with identical siteid(s) in both instances.
  3. Update appropriate connectToStaging script to reflect database name (if it's not muraDB). These scripts can be found in /config/setup/db/connectToStaging/*.sql.
  4. Run the connectToStaging script on the Production database

NOTE: I did not run the connectToStaging script because when I created the 2nd site, it was a complete copy of the other. The database too. As the sites were identical, I felt I didn't need to take this synchronization step.

The production instance should be ready to go at this point, and next you will set up the Staging instance to push content and assets to the Production instance.

Staging Instance Configuration

  1. Open settings.ini.cfm
  2. Set mode (mode=staging) in settings.ini.cfm
  3. Change the word "production" between the brackets ( [production] ) in the second set of settings to [staging]
  4. Set the following values to tell the staging instance where to push content and assets. These are just example settings and may not reflect your actual environment.
  5. view plain print about
    1productionDatasource=muraDB
    2 productionAssetPath=/tasks/sites
    3 productionWebroot=C:\Inetpub\mura\www
    4 productionFiledir=C:\Inetpub\mura\www\tasks\sites

    NOTE: In my case I only changed the productionDatasource and productionWebroot and left the others blank. productionAssetPath and productionFiledir both associate with AssetPath and Filedir which are both optional.

  6. In Site Settings, set your deployment preference to autodeploy or manual. Manual deployment can happen anytime (even if autodeploy is selected) by clicking the "lightning bolt" icon in the far right column.

For Production Here are a few more things I would recommend doing:

  1. Remove all but maybe 1 or 2 users from the Production Mura Admin.
  2. Turn off your Railo Administrator, or block access. See ColdFusion Joe - Hide, block and secure railo-context from your Railo Tomcat, JBoss, Resin servers
  3. Turn off your Mura Admin in production - using the urlrewrite filter. For details, see: ColdFusion Joe - SES URLs With Mura on Tomcat. Here's what we did differently with production's urlrewrite.xml

    view plain print about
    1<rule>
    2 <note>
    3 Makes all requests forward to /index.cfm/whatever-came-next
    4 Ignores admin URLs so the admin still works correctly for Mura.
    5 took 'admin' out of regex to turn off Mura admin - other stuff works.
    6 </note>
    7 <from>^/(?!plugins|js|css|assets|images|tasks|railo-context|flex2gateway|wysiwyg)(.*)$</from>
    8 <to>/index.cfm/$1</to>
    9 </rule>

    I just took "admin" out of the regular expression we are using to allow directories.

That is all you need to set up a staging and production environment in Mura. It's pretty easy. Something that may not be easy is figuring out where to "deploy the site to production" the site. I call it "promoting the site to production". As a super admin in Mura, click on Site Settings in the right side of the top yellow bar. You'll see your site. Just click on the little green sperm cell with an arrow head - lightening bolt?

More Entries

BlogCFC was created by Raymond Camden. This blog is running version 5.9.7. Contact Blog Owner