码迷,mamicode.com
首页 > 其他好文 > 详细

让nginx 的ssi支持include相对路径

时间:2014-10-15 18:27:41      阅读:434      评论:0      收藏:0      [点我收藏+]

标签:http   io   ar   文件   sp   on   问题   log   html   

好久没接触nginx了,今天帮同事解决一个客户的问题,顺便记录下;
version : nginx-1.6.2
问题描述:
客户的files.shtml里面include一个网站的头部文件( <!–# include file=”../../woqu.htm”–>),采用的是相对路径,这样的写法在apache里面可以正常访问,但是在nginx里面不能正常加载
日志上提示:
unsafe URI "../../woqu.html" was detected while sending response to client
解决方法:
修改源码重新编译nginx
vi src/http/modules/ngx_http_ssi_filter_module.c
注视掉下面这个判断:
/*
if (ngx_http_parse_unsafe_uri(r, uri, &args, &flags) != NGX_OK) {
return NGX_HTTP_SSI_ERROR;
}
*/
然后安装三部曲,reload一下就搞定了。
顺带说下,部分人在nginx里面为了安全会添加规则禁止访问隐藏文件(点 .开头),如:
location ~ (.*\.sh?$|/\.|.*\.log?$)
{
return 403;
}
然后就会跟我们上面改的起冲突,因为include ../../test.html 这样的时候,其实也是正常请求这样的一个URL,“..”也是点开头,然后你就会看到一个403的页面,好恶心。

让nginx 的ssi支持include相对路径

标签:http   io   ar   文件   sp   on   问题   log   html   

原文地址:http://www.cnblogs.com/jyb2014/p/4026654.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!