NGINX SSI Module


From Docunext Technology Wiki

Jump to: navigation, search

NGINX SSI Module Summary

I'm very pleased that NGINX has this module. SSI stands for server side includes, and they are about the simplest template system in existence. Several other web servers support server side includes, at least Apache does I know that for sure.

My Experience with SSIs

At first I disregarded SSIs because they were too simple and limited for complex tasks. They are often too limited, but a nice quality of simplicity is that there is less change of error (at least in theory).

SSI Example

In NGINX I'm using this for footer links:

<!--# block name="empty" --><!--# endblock -->
<!--# include virtual="/s/ssi/footer_links.html" stub="empty" -->
<!--# echo var="myhost" -->

This loads the footer_links.html file, and if it is unavailable substitutes the empty block instead. The virtual attribute is for http requests, so instead of an html file, a dynamic file could be requested to generate the block of content on the fly.

The last directive is an example of using a variable which can be set in the config file. For that variable to be set, I put this in my NGINX config file:

set $myhost $host;
Personal tools