Using dynamic SSI for simple sites

With the advent of modern feature-full web servers, most of them have Server-Side Includes (SSI) built in. Nginx provides easy SSI support which can let you do pretty much all basic web stuff.

How to do it...

Let's take a simple example and start understanding what one can achieve with it.

  1. Add the following code to the nginx.conf file:
    server {
    location / {
    ssi on;
    root /var/www/;
  2. Add the following code to the index.html file:
    <!--# block name="header_default" -->
    the header testing
    <!--# endblock -->
    <!--# include file="header.html" stub="header_default" →
    <!--# echo var="name" default="no" -->
    <!--# include file="footer.html"-->
  3. Add the following code to ...

Get Nginx 1 Web Server Implementation Cookbook now with O’Reilly online learning.

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