Hello,<br><br>Thanks for your reply! And I think the limit on the number is proper for most of the conditions. <br><br>However in our case, the index page may have hundreds of SSI &#39;include&#39; (combined from lots of our sub sites), and the number limitation may not be so proper.<br>
<br>So here I made a patch: For every &#39;include&#39;, a &#39;parents uri check&#39; is made. The patch is like this:<br><br><span style="color: rgb(102, 102, 102);">diff -crB <a href="http://nginx-0.7.65.org/src/http/modules/ngx_http_ssi_filter_module.c">nginx-0.7.65.org/src/http/modules/ngx_http_ssi_filter_module.c</a> nginx-0.7.65.patch/src/http/modules/ngx_http_ssi_filter_module.c</span><br style="color: rgb(102, 102, 102);">
<span style="color: rgb(102, 102, 102);">*** <a href="http://nginx-0.7.65.org/src/http/modules/ngx_http_ssi_filter_module.c">nginx-0.7.65.org/src/http/modules/ngx_http_ssi_filter_module.c</a>&nbsp;&nbsp;&nbsp; 2011-05-24 18:46:53.676370002 +0800</span><br style="color: rgb(102, 102, 102);">
<span style="color: rgb(102, 102, 102);">--- nginx-0.7.65.patch/src/http/modules/ngx_http_ssi_filter_module.c&nbsp;&nbsp;&nbsp; 2011-05-25 11:19:20.372370002 +0800</span><br style="color: rgb(102, 102, 102);"><span style="color: rgb(102, 102, 102);">***************</span><br style="color: rgb(102, 102, 102);">
<span style="color: rgb(102, 102, 102);">*** 2024,2029 ****</span><br style="color: rgb(102, 102, 102);"><span style="color: rgb(102, 102, 102);">--- 2024,2044 ----</span><br style="color: rgb(102, 102, 102);"><span style="color: rgb(102, 102, 102);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; flags |= NGX_HTTP_SUBREQUEST_IN_MEMORY|NGX_HTTP_SUBREQUEST_WAITED;</span><br style="color: rgb(102, 102, 102);">
<span style="color: rgb(102, 102, 102);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</span><br style="color: rgb(102, 102, 102);"><span style="color: rgb(102, 102, 102);">&nbsp; </span><br style="color: rgb(102, 102, 102);"><span style="color: rgb(102, 102, 102);">+&nbsp;&nbsp;&nbsp;&nbsp; ngx_http_request_t *ir = r;</span><br style="color: rgb(102, 102, 102);">
<span style="color: rgb(102, 102, 102);">+&nbsp;&nbsp;&nbsp;&nbsp; for(;ir != NULL;ir = ir-&gt;parent) {</span><br style="color: rgb(102, 102, 102);"><span style="color: rgb(102, 102, 102);">+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ngx_log_debug4(NGX_LOG_DEBUG_HTTP, r-&gt;connection-&gt;log, 0,</span><br style="color: rgb(102, 102, 102);">
<span style="color: rgb(102, 102, 102);">+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &quot; include path: %V, args: %V; parent path: %V, args: %V&quot;,</span><br style="color: rgb(102, 102, 102);"><span style="color: rgb(102, 102, 102);">+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; uri, &amp;args, &amp;ir-&gt;uri, &amp;ir-&gt;args);</span><br style="color: rgb(102, 102, 102);">
<span style="color: rgb(102, 102, 102);">+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (uri-&gt;len == ir-&gt;uri.len</span><br style="color: rgb(102, 102, 102);"><span style="color: rgb(102, 102, 102);">+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &amp;&amp; args.len == ir-&gt;args.len</span><br style="color: rgb(102, 102, 102);">
<span style="color: rgb(102, 102, 102);">+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &amp;&amp; ngx_strncmp(uri-&gt;data, ir-&gt;uri.data, uri-&gt;len) == 0</span><br style="color: rgb(102, 102, 102);"><span style="color: rgb(102, 102, 102);">+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &amp;&amp; ngx_strncmp(args.data, ir-&gt;args.data, args.len) == 0) {</span><br style="color: rgb(102, 102, 102);">
<span style="color: rgb(102, 102, 102);">+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ngx_log_error(NGX_LOG_ERR, r-&gt;connection-&gt;log, 0,</span><br style="color: rgb(102, 102, 102);"><span style="color: rgb(102, 102, 102);">+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &quot;A loop include \&quot;%V\&quot; is found&quot;, uri);</span><br style="color: rgb(102, 102, 102);">
<span style="color: rgb(102, 102, 102);">+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return NGX_HTTP_SSI_ERROR;</span><br style="color: rgb(102, 102, 102);"><span style="color: rgb(102, 102, 102);">+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</span><br style="color: rgb(102, 102, 102);">
<span style="color: rgb(102, 102, 102);">+&nbsp;&nbsp;&nbsp;&nbsp; }</span><br style="color: rgb(102, 102, 102);"><span style="color: rgb(102, 102, 102);">+ </span><br style="color: rgb(102, 102, 102);"><span style="color: rgb(102, 102, 102);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (ngx_http_subrequest(r, uri, &amp;args, &amp;sr, psr, flags) != NGX_OK) {</span><br style="color: rgb(102, 102, 102);">
<span style="color: rgb(102, 102, 102);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return NGX_HTTP_SSI_ERROR;</span><br style="color: rgb(102, 102, 102);"><span style="color: rgb(102, 102, 102);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</span><br style="color: rgb(102, 102, 102);"><br>
Hope for any reply of my patch !<br><br>And thanks to my fellow 姚伟斌 for reminding me on the &#39;args&#39; check!<br><br><br><div class="gmail_quote">On Tue, May 24, 2011 at 8:59 PM, Maxim Dounin <span dir="ltr">&lt;<a href="mailto:mdounin@mdounin.ru">mdounin@mdounin.ru</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">Hello!<br>
<div><div></div><div class="h5"><br>
On Tue, May 24, 2011 at 10:49:45AM +0800, eagle sbc wrote:<br>
<br>
&gt; Hello,<br>
&gt;<br>
&gt; I&#39;ve encountered a problem about &quot;SSI include infinite loop&quot;.<br>
&gt;<br>
&gt; We have a system that our editors can compose a html page from some<br>
&gt; templates using SSI. Sometimes unwarily combination will cause infinite<br>
&gt; loop, such as &#39;A include A&#39;, &#39;A include B, B include A&#39;, or even &#39;A include<br>
&gt; B, B include C, C include A&#39;. And this page will cause nginx eating up all<br>
&gt; memories, and certainly won&#39;t serve any more unless we restart nginx.<br>
&gt;<br>
&gt; I&#39;m wondering is there any solution for this problem? Or other ways to avoid<br>
&gt; this?<br>
&gt;<br>
&gt; I&#39;ve googled apache and lighttpd, and there also no official solution for<br>
&gt; this, unless lightptd has a patch which will limit the whole &#39;include&#39;<br>
&gt; count, and I think it&#39;s just a tricky way to fix the infinite loop.<br>
&gt;<br>
&gt; Thanks a lot for any help!<br>
<br>
</div></div>Number of in-flight ssi includes used to be limited in nginx,<br>
though this limit was broken somewhere near 0.7.25.<br>
<br>
This patch brings it back:<br>
<br>
<a href="http://nginx.org/pipermail/nginx-devel/2011-February/000746.html" target="_blank">http://nginx.org/pipermail/nginx-devel/2011-February/000746.html</a><br>
<br>
Maxim Dounin<br>
<br>
_______________________________________________<br>
nginx mailing list<br>
<a href="mailto:nginx@nginx.org">nginx@nginx.org</a><br>
<a href="http://nginx.org/mailman/listinfo/nginx" target="_blank">http://nginx.org/mailman/listinfo/nginx</a><br>
</blockquote></div><br><br clear="all"><br>-- <br><font color="#333333"><font face="&#39;comic sans ms&#39;, sans-serif">自由是我生命之基石,尊重是我行为之准绳</font></font><div><font color="#333333"><font face="&#39;comic sans ms&#39;, sans-serif">也许我以千百种方式生活在这世上,但我坚守我人生之信仰</font></font></div>
<div><font color="#333333"><font face="&#39;comic sans ms&#39;, sans-serif">所以,我的朋友</font></font></div><div><font color="#333333"><font face="&#39;comic sans ms&#39;, sans-serif">请平视的看着我,</font></font><span style="color: rgb(51, 51, 51);"><font face="&#39;comic sans ms&#39;, sans-serif">带着你的微笑</font></span></div>
<div><font color="#333333"><br></font></div><br>