Portable Webserver Filter

By | January 12, 2018

I am working on a project that involves modifying (not generating) content as it flows through a webserver, and would like a portable way to do this.

For the sake of discretion, let’s say this project automatically minifies the HTML/JS/CSS before it goes out to the client (this is not actually what the project does, but is close enough to understand the basic concept).

Currently, we use a different module for each webserver; this approach works fine for a small number of closely related web servers (Apache and Nginx ironically have very similar API’s that can be easily wrapped), but obviously this approach will become more and more untenable as the project expands.

So, I am looking for a light weight approach, one that:

  1. Does not require the filter to load the content itself (full webservers are much better at this than I).
  2. Does not require the filter to transmit the content to the end client (same as above)
  3. Is portable between (at least) major web servers

The first requirement strikes out my filter being a content generator and the second strikes out being an HTTP filter. I had looked into FastCGI, but it’s filter mode is not widely supported (if I am wrong, or there is an easy way to configure FastCGI as a filter on most web servers, this is preferred). SCGI looks easy enough, but I can find no documentation on using SCGI modules as filters.

Is there a portable and light weight solution to providing a web server filter?


I think your best option is to use a TCP proxy which can be cross OS standalone compilable and sits in front (or behind) of any webserver. You can design your own filter mechanism inside this.
Looking for an add-in which works with all webservers takes a lot of development.

Leave a Reply

Your email address will not be published. Required fields are marked *