标签:
也就是说,在server{}块配置项内定义了该虚拟主机所要监听的port。
ngx_http_core_module是HTTP模块。所以它会调用ngx_http_module_t接口内的ngx_http_core_create_main_conf方法创建存储main级别配置项的结构体,函数例如以下:
static void *
ngx_http_core_create_main_conf(ngx_conf_t *cf)
{
ngx_http_core_main_conf_t *cmcf;
....
return cmcf;
}typedef struct {
....
ngx_array_t *ports; /* 保存http块配置项内监听的全部端口 */
....
} ngx_http_core_main_conf_t;
每个端口用结构体ngx_http_conf_port_t表示:
typedef struct {
ngx_int_t family;
in_port_t port;
ngx_array_t addrs; /* array of ngx_http_conf_addr_t */
} ngx_http_conf_port_t;typedef struct {
ngx_http_listen_opt_t opt;
ngx_hash_t hash;
ngx_hash_wildcard_t *wc_head;
ngx_hash_wildcard_t *wc_tail;
#if (NGX_PCRE)
ngx_uint_t nregex;
ngx_http_server_name_t *regex;
#endif
/* the default server configuration for this address:port */
ngx_http_core_srv_conf_t *default_server;
ngx_array_t servers; /* array of ngx_http_core_srv_conf_t */
} ngx_http_conf_addr_t;也就是说。每一个监听地址ngx_http_conf_addr_t中的servers数组中关联着监听地址相应的server{}虚拟主机。
版权声明:本文博主原创文章,博客,未经同意不得转载。
标签:
原文地址:http://www.cnblogs.com/bhlsheji/p/4877480.html