On Fri, Apr 13, 2012 at 6:06 AM, ruijf
<reply+i-4098246-aa357b79f04af9f3bc3a10cf9f7c65bb510e45af-56241@reply.github.com>
wrote:
> location = /tt {
> default_type 'text/html';
> expires -1;
> set $ud "aaaaaaaa";
> if ($http_user_agent ~ MSIE) {
> set $ud "bbbbbbbbb";
> }
> redis2_query incr "a1";
> redis2_query sadd "ud" $ud;
> redis2_pass redis_server;
> }
> 这个配置会出现500错误,如果去掉
> if ($http_user_agent ~ MSIE) {
> set $ud "bbbbbbbbb";
> }
> 就没OK。我的版本是1.0.12
>
每当我们看到 500 错误页,就应该检查立即检查 nginx 的错误日志文件 error.log 里面有没有出错提示。
另外,你的 location 中的 if 使用不正确,因为 if { ... } 块会隐式创建一个嵌套在 location = /tt
中的匿名 location 配置块,而且一旦条件匹配,就会使用该配置块,而不会再使用外部的 location = /tt,再加上
ngx_redis2 模块的 redis2_pass 并不支持父子 location 间的自动继承,所以这个配置是明显有问题的。关于
location 配置块内部使用 if 指令的相关问题,可以参考我的这一篇博客:
http://agentzh.blogspot.com/2011/03/how-nginx-location-if-works.html
祝好运!
-agentzh
P.S. 同时抄送给 openresty 邮件组:https://groups.google.com/group/openresty