发现还是有问题:我的my_module_func需要对http请求头进行处理,是不是意味着my_module_func无法在rewrite阶段执行?rewrite的handler没有ngx_http_request_t*
变量。
我的一个已有实现思路:写一个处理模块对http请求头进行操作,根据操作结果调用ngx_http_finalize_request(r,
result_code),然后在配置文件中用error_page将不同的result_code重定向到对应的location。如下所示:
Hello!
2012/6/1 huangfxbupt <huang...@gmail.com>:
> my_module_fun_result是一个变量。
> 注册到rewrite阶段,能保证location/test 中的执行顺序是 my_module_func ->
> if(my_module_fun_result),并且在if(...) 时my_module_fun_result已是模块中的赋值?
> 新手,非常感谢~~
>
用户注册在 rewrite 阶段的模块如自己不做特殊处理,都会运行在标准的 ngx_rewrite 模块之前(而 if 配置指令是
ngx_rewrite 模块提供的)。
考虑到:
1. ngx_rewrite 模块运行在 rewrite 阶段,所以你的模块必须运行在 rewrite 阶段之前(含 rewrite 阶段)。
2. 同时由于你又需要在 location 配置块中进行开关,所以你的模块的运行阶段须在 find-config 阶段之后。
综合 1 与 2,再加上 find-config 阶段之后紧接着的便是 rewrite 阶段,所以 rewrite 阶段是唯一选择。
关于请求处理阶段的更多信息,可以参见我的 nginx 连载教程:
http://agentzh.org/misc/nginx/agentzh-nginx-tutorials-zhcn.html#02-NginxDirectiveExecOrder01
Regards,
-agentzh
--
邮件自: 列表“openresty”,专用于技术讨论!
发言: 请发邮件到 openresty@googlegroups.com
退订: 请发邮件至 openresty+unsubscribe@googlegroups.com
详情: http://groups.google.com/group/openresty
官网: http://openresty.org/
仓库: https://github.com/agentzh/ngx_openresty
建议: 提问的智慧 http://wiki.woodpecker.org.cn/moin/AskForHelp
教程: http://agentzh.org/misc/nginx/agentzh-nginx-tutorials-zhcn.html