Nginx之HTTP模块

HTTP模块

Nginx源码目录中在src/http

客户端请求到Nginx中时,HTTP在Nginx中的执行流程可以分为11执行阶段,这个是在ngx_http_core_module.h中已经事先定义好的

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_PRECONTENT_PHASE,

    NGX_HTTP_CONTENT_PHASE,

    NGX_HTTP_LOG_PHASE
} ngx_http_phases;

一个配置块的示例

main
http {
            upstream {  ... }
            split_clients { ... }
            map {  ... }
            geo {  ...  }
            server {
                        if (){  ... }
                        location / { 
                                limit_except { ... }
                        }
            }       
}

相应的参数要放到对应的指令块中,不然Nginx语法不能通过,检测Nginx配置的命令./nginx/sbin/nginx -t

server指令块的设置

Syntax: server { ... }
Default:    —
Context:    http #只在http指令块中生效

你可能感兴趣的:(Nginx之HTTP模块)