Nginx SSI instruction configuration details

  • 2020-05-09 19:53:58
  • OfStack

What is a SSI

Server Side Include, commonly referred to as server-side embedding, is a server-based web authoring technique similar to ASP. The SSI command is supported by most WEB servers (Unix platform-based Netscape Enterprise Server).

Why SSI

As an example, a static page needs to be embedded with a small piece of real-time changing content. For example, the homepage, most of the page content needs to be cached, but the personal information after the user logs in is dynamic information, which cannot be cached. Then, how to solve the problem of "page partial caching" can be solved by using SSI. The dynamic page of personal information is embedded in the static page of the home page. As it is embedded on the server side, the user will only have one embedded page when browsing.

nginx configuration SSI

The three main parameters, ssi, ssi_silent_errors and ssi_types, can be placed under the scope of http,server and location.

ssi on

ssi support is enabled, and off is the default

ssi_silent_errors on

The default value is off, and no error message is printed when processing SSI file error after opening: "[an error occurred while processing the directive]"

ssi_types

The default is ssi_types text/html, so if you need htm and html support, you don't need to set this sentence. If you need shtml support, you need to set ssi_types text/shtml

Configuration on page


<! � # include file= " /m/2013/4/15/index_top.html " � >

Xml code

<! � # include virtual= " /m/2013/4/15/index_top.html " � > 

The sample
1. File names with the shtml suffix enabled support ssi


server{ 
...  
ssi on; 
ssi_silent_errors on; 
ssi_types text/shtml; 

2. Open the html suffix to support ssi


server{ 
...  
ssi on; 
ssi_silent_errors on; 

3. Open the html suffix in the zt directory to support ssi


server{ 
...  
location /hx/{ 
ssi on; 
ssi_silent_errors on; 

}


Related articles: