For the last couple of weeks, I've been working on a ColdFusion server migration. And, unfortunately, the last 80% of that effort has been put into getting Helicon Ape and, specifically, X-SendFile (mod_xsendfile), to serve up files that are outside of the ColdFusion web-root. Finally, this morning, after much back-and-forth with both my server team as well as the Helicon Ape tech support team, we've got it working! It wasn't easy, so I thought I would share my journey.
Using Helicon Ape For Both URL-Rewriting (mod_rewrite) And X-SendFile (mod_xsendfile)
On my old server, I was using the Ionic ISAPI Rewrite filter to perform URL-rewriting and Helicon Ape / X-SendFile to serve files. As I migrated to the new server, I thought it would be a great opportunity to ditch the old ISAPI filter approach and move my URL rewriting over to Helicon Ape. This way, all my "Apache" functionality would be consolidated in the Helicon Ape pipeline.
Unfortunately, this plan was a no-go. Helicon Ape's URL Rewriting doesn't work so well when you are rewriting to a ".cfm" page. Of course, you can get the URL rewriting to work by making sure that your ".cfm" mappings point to the wildcard connector:
However, if you do this, Helicon Ape's X-SendFile functionality stops working, according to Helicon Ape Tech support:
It's a known issue that after jrun_iis6_wildcard.dll the request processing in IIS stops, which means that Helicon Ape doesn't receive the events that are executed after the handler. Mod_xsendfile, in its turn, takes place after the handler ... This means that mod_xsendfile cannot work together with ColdFusion using jrun_iis6_wildcard.dll.
As such, we had to revert back to Ionic ISAPI rewrite filter so that we can could rebind the standard jrun_iis6.dll connector. This way, IIS would continue to process the page after it was sent to ColdFusion, allowing us to set the "x-sendfile" CFHeader value.
NOTE: I could have started using IIS's URL Rewriting module; I'm just more comfortable with the Apache-compatible syntax.
Using Helicon Ape With Only X-SendFile (mod_xsendfile)
After we reverted back to Ionic ISAPI Rewrite for the URL rewriting, I thought we were in the clear. But, unfortunately, X-SendFile continued to fail. This was super frustrating because there were no errors; it just didn't work. In fact, even the Helicon Ape error log seemed to be reporting an OK success:
X-Sendfile: C:\Websites\example.com\wwwroot\test\image.png - OK
After inspecting the HTTP response (200 OK) of the test page, I saw that the "x-sendfile" response header was still in-tact. This is a telltale sign that X-SendFile (mod_xsendfile) is not serving up the file as it [mod_xsendfile] will strip out the "x-sendfile" header.
At this point, I had no idea what to do. So, I purchased some premium support for Helicon Tech; and, after a few days of back-and-forth, they were able to narrow down the problem. Apparently, my wildcard URL handler mapping in IIS had an incompatible buffer limit:
Notice that the mapping defines a "responseBufferLimit" of zero. This is an optional setting that, according to the IIS documentation, "Specifies the maximum size, in bytes, of the response buffer for a request handler." By removing this attribute, it allowed X-SendFile to successfully stream the binary file content!
It was quite a journey; but, we finally made it! I hope this helps anyone else who might be having trouble with getting ColdFusion, Helicon Ape, URL rewriting, and X-SendFile to work with IIS.