Sunday, March 19, 2017

Configuring Lucee to take over http error handling instead of IIS

By default, Lucee seems to be configured with it's configured to hand-off all non-200 response codes to IIS to display using whatever setting you've enabled in web.config

Which is great... except, you need detailed errors enabled for your site in order for Lucee to render its own error messages... which means any request for a static file, like a missing image ( or static non cfc /cfm ) will get handled directly by IIS... and show DETAILED errors... no good!

Just read in the Lucee forum the following from @bilal:!searchin/lucee/error$20messages$20iis$20%7Csort:relevance/lucee/nSahG_wXzPk/Ck545qZbCwAJ

Step 0) Throw a 500 in Lucee. IIS will take over with a bland 500 error stripe message. Poop!

Step 1) Skip IIS Custom Errors

In C:\Windows\BonCodeAJP13.settings file, add 'SkipIISCustomErrors' ( See Tomcat Connector Docs for details )


This will let you control status codes other than 200 with custom messages from Lucee. IIS will still be able to use the standard 404-custom error page for non-cfm related error handling, e.g. when a non-existing image file is requested etc.

Step 2) Set IIS errors to return "Custom Error Pages"

Step 3) Throw a 500 in Lucee. You should see your error ( And you should render it properly for security )