Mastering Nginx

(Ron) #1
Chapter 7

[ 175 ]

An SSI file is nothing more than an HTML file with these commands embedded


within comments. That way, if ssi isn't enabled for a particular location that
contains such a file, the HTML portion will still render, albeit incompletely.


The following is an example of an SSI file which uses calls to a subrequest to render


the header, footer, and menu of a page:


<html>
<head>
<title>*** SSI test page ***</title>
<link rel="stylesheet" href="/css/layout.css" type="text/css"/>
<!--# block name="boilerplate" -->
<p>...</p>
<!--# endblock -->
</head>
<body>
<div id="header">
<!--# include virtual="/render/header?page=$uri"
stub="boilerplate" -->
</div>
<div id="menu">
<!--# include virtual="/render/menu?page=$uri"
stub="boilerplate" -->
</div>
<div id="content">
<p>This is the content of the page.</p>
</div>
<div id="footer">
<!--# include virtual="/render/footer?page=$uri"
stub="boilerplate" -->
</div>
</body>
</html>

The stub is used to render some default content in case of an error in processing


the subrequest.


If these primitives don't offer enough flexibility in processing logic, you can


use the embedded perl module to solve just about any other processing or
configuration need you may have.

Free download pdf