读书人

Nginx include授命的测试

发布时间: 2012-07-22 19:31:17 作者: rapoo

Nginx include指令的测试

需求:

淘宝的Tengine服务器在1.0.1版本的时候对Include指令进行了增强:

?

location ~ /er.* { error_page 404 /404_1.html; } location ~ /err.* { error_page 404 /404_2.html; }

?

?访问url: http://serverip:port/error/pageNotExit;

?返回: 404_1.html页面;

?

?访问url: http://serverip:port/eroor/pageNotExit;

?返回: 404_1.html页面;

?

案例二:

当配置文件内的location配置如下时:

?

        location ~ /err.* {            error_page 404 /404_2.html;        }        location  ~ /er.* {            error_page 404 /404_1.html;        }

?访问url: http://serverip:port/error/pageNotExit;

?

?返回: 404_2.html页面;

?

?访问url: http://serverip:port/eroor/pageNotExit;

?返回: 404_1.html页面;

?

因此,我们只需要在将这两个location配置写如不同的文件中:

?

server { listen 8099; server_name localhost; include location/*.conf;}?

那么通过设计特定的url访问并检查返回结果就可以测试include指令对多个文件的包含顺序了。

?

ok, ?Nginx include指令的测试介绍完毕, 欢迎拍砖。转发请备注转自:100continue.iteye.com。 谢谢。

读书人网 >开源软件

热点推荐