nginx总共有3种类型的模块 handler,filter,upstream。upstream为一种特殊的handler模块,因为upstream模块的输出都来自于upstream。
编写upstream模块非常常见,nginx中常见的upstream模块为:memcached,proxy,scgi,uswgi,fastcgi 。nginx将他的处理工作分为11个阶段,其中4个为只能有一个handler函数,7个阶段为可以有多个处理函数,各个阶段的类型如下图所示:
-
typedef enum {
-
NGX_HTTP_POST_READ_PHASE = 0,
-
-
NGX_HTTP_SERVER_REWRITE_PHASE,
-
-
NGX_HTTP_FIND_CONFIG_PHASE,
-
NGX_HTTP_REWRITE_PHASE,
-
NGX_HTTP_POST_REWRITE_PHASE,
-
-
NGX_HTTP_PREACCESS_PHASE,
-
-
NGX_HTTP_ACCESS_PHASE,
-
NGX_HTTP_POST_ACCESS_PHASE,
-
-
NGX_HTTP_TRY_FILES_PHASE,
-
NGX_HTTP_CONTENT_PHASE,
-
-
NGX_HTTP_LOG_PHASE
-
} ngx_http_phases;
其中NGX_HTTP_POST_READ_PHASE
NGX_HTTP_SERVER_REWRITE_PHASE,
NGX_HTTP_REWRITE_PHASE,
NGX_HTTP_PREACCESS_PHASE,
NGX_HTTP_ACCESS_PHASE,
NGX_HTTP_CONTENT_PHASE,
NGX_HTTP_LOG_PHASE
这几个字段是可以设置多个handler函数的。
阅读(644) | 评论(0) | 转发(0) |