Nginx源码研究十四:ngx_http_core_run_phases

 

    if (ngx_http_init_phases(cf, cmcf) != NGX_OK) {
        return NGX_CONF_ERROR;
    }

    if (ngx_http_init_headers_in_hash(cf, cmcf) != NGX_OK) {
        return NGX_CONF_ERROR;
    }


    for (m = 0; ngx_modules[m]; m++) {
        if (ngx_modules[m]->type != NGX_HTTP_MODULE) {
            continue;
        }

        module = ngx_modules[m]->ctx;

        if (module->postconfiguration) {
            if (module->postconfiguration(cf) != NGX_OK) {
                return NGX_CONF_ERROR;
            }
        }
    }

 

 

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;

 

序号 enum module checker
0 NGX_HTTP_POST_READ_PHASE ngx_http_realip_module ngx_http_core_generic_phase
1 NGX_HTTP_SERVER_REWRITE_PHASE ngx_http_rewrite_module ngx_http_core_rewrite_phase
2 NGX_HTTP_FIND_CONFIG_PHASE   ngx_http_core_find_config_phase
3 NGX_HTTP_REWRITE_PHASE ngx_http_rewrite_module ngx_http_core_rewrite_phase
4 NGX_HTTP_POST_REWRITE_PHASE   ngx_http_core_post_rewrite_phase
5 NGX_HTTP_PREACCESS_PHASE ngx_http_degradation_module ngx_http_core_generic_phase
ngx_http_limit_conn_module
ngx_http_limit_req_module
ngx_http_realip_module
6 NGX_HTTP_ACCESS_PHASE ngx_http_access_module ngx_http_core_access_phase
ngx_http_auth_basic_module
7 NGX_HTTP_POST_ACCESS_PHASE   ngx_http_core_post_access_phase
8 NGX_HTTP_TRY_FILES_PHASE   ngx_http_core_try_files_phase
9 NGX_HTTP_CONTENT_PHASE ngx_http_autoindex_module ngx_http_core_content_phase
ngx_http_dav_module
ngx_http_gzip_static_module
ngx_http_index_module
ngx_http_random_index_module
ngx_http_static_module

 

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。