Research on SSI problem in Nginx, Nginxssi problem Research _php Tutorial

Source: Internet
Author: User
Tags php framework nginx server

Research on SSI problem in Nginx and Nginxssi problem


Recently feel very cool, this project team did not have a special PHP, I was the first to come in to do PHP (and of course, front end), haha, I will design and modify the appropriate PHP framework for our business, haha, the feeling will learn a lot of things look, a few days ago in the group 20 of several predecessors speak PHP framework, And Daniel to discuss the appropriate PHP framework for us, feeling expressive ability is too poor, know what the expression is not clear, but also my mentor to help me express, here thanks to my mentor Yu Honglei (Lei elder brother), Lei elder brother is my idol, I have not seen so deep programmer, Technical cow B This is certain, Outside of the technical knowledge beyond my imagination, lei brother read a lot of books, especially in the history and literature, talk about the days to have a reason, humorous, and occasionally quote a few who who's article, Ah! Really feel not come out is a technology Daniel, more like Yonghao, Haha, in the last 2 years Lei elder brother is my goal, more reading, more speech, improve their ability to express, otherwise they know things can not through the most direct expression to share out, this is very depressed.

So much nonsense, go to the point, today is to say a question about SSI, here first introduce SSI

SSI is the abbreviation of server Side Inclde, is the service side contains the meaning, what I want to say today only uses the Nginx module's include command, this command will contain a page, and then expand in the Nginx server.

What's the problem I'm having? Now there's a rich text editor that asks to save the page, enter some HTML (including the SSI include command), save it in the database, and then ask to edit it after saving, asking for content like this in the rich text editor like this:

 
  Hello World!!!

The problem is here, which includes the SSI command.

This if the direct access only shows Hello world!!! , we do the following configuration for Nginx:

SSI On;ssi_types text/html;

This time, if there is a MIME type of text/shtml types of data through Nginx, Nginx went back to parse these commands, which led to a problem, I found the data in the database and then returned to the client Rich text editor will be wrong, my echo content is as follows:

 
  
 
  
 
  

The page will show this form:

I'm a bit depressed, because the other features on the server have to use SSI, and I don't need it here.

This time I think of Ssi_types, which is set in text/html, and often there is a text/plain, this type of mime is what, in the browser he will all the contents of the display intact, not to parse HTML, CSS. With this type, Nginx will not be expanded, try to modify the mime before the output:

Header (' Content-type:text/plain ');

Sure enough, after modifying the MIME, the output is consistent with the database, unchanged:

It seems that the problem solved, but did not think for historical reasons, the background of the edit box content and other content is returned together, this embarrassed, if set to Text/plain all the content has been displayed in the text format in the browser, the problem is still not resolved ~ ~

This time to think of nginx configuration, due to the need for Nginx parsing expanded files are generally shtml, HTML and other suffixes, and check the database is generally PHP so I can use SSI to reduce the suffix called shtml, HTML files, look at the configuration, Here I talk about the SSI configuration information moved to a match, and then look at the effect,

        Location ~* \. (html|shtml|htm) $ {            SSI on;            Ssi_types text/shtml;            Proxy_pass http://www.testssi.com;        }

New HTML, PHP files, similar content,

 
  '; Echo '; Echo ';
 
  
 
   echo ' test!! ';

Html:

 
  
 
  
 
  test!!

Will find PHP access only output test!!, other content to see the source code can be seen, the HTML will be parsed, the output corresponding to include the contents of the file or did not find an error!! This problem basically solved, the specific situation after work next week to try this method, should be no problem, the test is OK.

This copyright belongs to the author Iforever (luluyrt@163.com) all, without the author's consent to prohibit any form of reprint, reprinted article must be in the article page obvious location to the author and the original text connection.

http://www.bkjia.com/PHPjc/981699.html www.bkjia.com true http://www.bkjia.com/PHPjc/981699.html techarticle Research on SSI problem in Nginx, Nginxssi problem Research recently feel very good, this project team did not have a special PHP, I was the first to come in to do PHP (and of course, the front), ha ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.