Wednesday, March 17, 2010

Servlet + SSI + Apache HTTPD

I was confronted with a requirement to add some SSI (Server Side Includes) processing to my Java web app. The application would get some external text containing SSI tags, prepend it with text containing SSI #set tags which will set some needed variables and all this would be processed by SSI to get the final HTML. Sounds easy enough.

What I've found is that SSI is not actually a standard - it is more like an Apache HTTPD proprietary feature. Some other webservers claim to support it (most notably Tomcat), but certainly not 100%. For example, Tomcat does not understand regular expressions in #if tags and this makes Tomcat SSI totally unusable for my purpose.

So, the only working solution right now is to have Apache in front of Tomcat (or other servlet container) with help of mod_jk or mod_proxy.

After couple of hours try-and-fails, I have found how to configure it in httpd.conf:

<Proxy *>
  Options IncludesNoExec
  SetOutputFilter INCLUDES
  Order deny,allow
  Allow from all

The critical part here is the first two lines inside

No comments: