Nginx, Strip All Newlines Using nginx-nonewlines Module

nginx logo
Nginx

Another Nginx module i’ve tested today, nginx-nonewlines , basically, this module same as Evan Miller’s nginx mod_strip module , Evan Miller’s mod_strip module removes unnecessary whitespace (spaces, tabs, and newlines) from HTML documents and automatically leaves comments as well as <pre></pre> tags untouched. while using using nginx-nonewlines we should define  <!–SC_OFF–> and  <!–SC_ON–> within the html code area that we’re intend to leaves them intact.

Here’s quick and dirty compiling nginx-nonewlines module

  • download the module
https://github.com/vedang/nginx-nonewlines/archives/master
  • add this line to ./configure step, compile and install
  # ./configure \
  ....
  ....
  --add-module=/path/to/vedang-nginx-nonewlines-ba02b59
  ....
  ....
  # make && make install

add folowwing directive to nginx’s config.