Fixing minor issues moving code from Railo to Lucee ColdFusion

I have a couple of personal projects at a host that offers the ColdFusion web programming language. I have a soft spot for ColdFusion as its my first programming language and I still find it very easy to put together sites in it as it comes with easy to use functionality the other server side language I use a lot, PHP, only gets through frameworks where they’ve been added by others.

Adobe, current owners of the official ColdFusion engine, charge rather a lot for licenses and that has a knock on effect on the price of hosting. So, I use Viviotech, who offer the open source engines that run the ColdFusion language. The popular one of those was Railo and is now Lucee. Viviotech recently shifted my sites onto Lucee, which I’d been meaning to try as Railo is old and now discontinued.

I hit a couple of problems:

Gotcha 1: No CGI.PATH_INFO

In the project, I redirect all requests through a single routing file. Within that file, I was using CGI.PATH_INFO to get the path of the page being requested. That stopped working, which turns out to be because the host is using Nginx and that doesn’t have PATH_INFO turned on by default. There are ways of making it work, but I didn’t want to be doing support requests to do that and it may not have been accepted for my cheap-as-chips hosting package.

Instead, I make the redirect in the .htaccess file send the path through for me.

My redirect went from this:
RewriteRule ^(.*)$ ./routing.cfm/$1 [L]
To this:
RewriteRule ^(.*)$ /routing.cfm?path=$1 [NC,L,QSA]
Which gives me the URL of the page being requested in URL.path (apart from the / that is normally at the start, which I needed in part of my URL detection, so I added it on.)

I re-wrote my code to use the new URL.path (with added /) instead of CGI.PATH_INFO and that got it working again.

Gotcha 2: Saving files needs permissions set

In one of the sites, I get an image from an API that makes screenshots, and save it locally so I don’t have to use the API over and over. That means getting the image using CFHTTP, then saving it using CFFILE.

That worked, but I couldn’t open the files. The fix was to use MODE=”644″ within CFFILE. This set the file permissions so the image file can be read by the world, and show up on a web page.

action = "write"
file = "<path><filename>"
output = "#cfhttp.fileContent#"

Improvement: Can read SSL protected RSS feeds

Railo couldn’t read RSS feeds that were protected by Let’s Encrypt SSL certificates and some of the other cheap/free SSL providers. Lucee can.

That’s great, as I made a very basic proxy (not really worthy of the word) to go request the SSL protected RSS feed through a PHP script I had on some other hosting, which would then send it through without SSL. Not great for security (although these are all public posts it is reading.) So the update to Lucee let me remove the ‘proxy’, which has simplified my code and maintenance.

Now I have my sites working again, I’m looking forward to delving into Lucee some more.

Leave a Reply

Your email address will not be published.