nginx 11処理フェーズ&&nginx lua 8処理フェーズ

1819 ワード

1.nginx 11個の処理段階
nginxは実際に要求処理プロセスを11段階に分けている.このように分けたのは、要求の実行ロジックを細分化し、各段階は処理タイミングに応じて明確な実行意味を定義しているため、開発者は自分が開発するモジュールがどの段階に定義すべきか、http/ngx_に定義すべきかを簡単に見分けることができる.http_core_module.hには次の定義があります.
NGX_HTTP_POST_READ_PHASE:
              ,   uri    ,               ,      ,      

NGX_HTTP_SERVER_REWRITE_PHASE:
server   uri    ,          server  ,location       ,          nginx   host              

NGX_HTTP_FIND_CONFIG_PHASE:
  location    ,          uri      location,                 ,      location       

NGX_HTTP_REWRITE_PHASE:
location   uri    ,     location       ,         

NGX_HTTP_POST_REWRITE_PHASE:
location         ,          uri  ,             

NGX_HTTP_PREACCESS_PHASE:
           ,            ,         ,        ,    

NGX_HTTP_ACCESS_PHASE:
        ,    ip         ,             

NGX_HTTP_POST_ACCESS_PHASE:
          ,                      

NGX_HTTP_TRY_FILES_PHASE:
try_files       ,      try_files  ,       

NGX_HTTP_CONTENT_PHASE:
      ,       ,       

NGX_HTTP_LOG_PHASE:
      ,         

2.nginx luaの8つの処理段階
init_by_lua            http
set_by_lua             server, server if, location, location if
rewrite_by_lua         http, server, location, location if
access_by_lua          http, server, location, location if
content_by_lua         location, location if
header_filter_by_lua   http, server, location, location if
body_filter_by_lua     http, server, location, location if
log_by_lua             http, server, location, location if
{
	set_by_lua:              
	rewrite_by_lua:   、   、     (           )
	access_by_lua: IP  、           (    iptable       )
	content_by_lua:     
	header_filter_by_lua:   HTTP    (        )
	body_filter_by_lua:   BODY    (             )
	log_by_lua:                (         ,          )
}