Changing content on-the-fly

Sometimes it may be helpful post-process what comes from your application. Maybe you would like to add a string at a certain point in your page to show which frontend server delivered that page to the client. Or maybe you would like to perform a transformation on the rendered HTML page. NGINX provides three modules that could be useful here: the addition module, the sub module, and the xslt module.

The addition module

The addition module works as a filter to add text before and/or after a response. It is not compiled by default, so if you want to make use of this feature, you must enable it at configure time by adding --with-http_addition_module.

This filter works by referencing a subrequest, which is then either appended ...

Get Mastering NGINX now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.