歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> 關於Linux >> 配置、error日志和請求上下文

配置、error日志和請求上下文

日期:2017/3/1 12:02:34   编辑:關於Linux

http配置項的使用場景

http{
    test_str main;
    server{
        listen 80;
        test_str server80;

        location /url1{
            mytest;
            test_str loc1;
        }
        location /url2{
            mytest;
            test_str loc2;
        }
    }
    server {
        listen 8080;
        test_str server8080;
        location /url3{
            mytest;
            test_str loc3;
        }
    }
}

怎樣使用http配置

創建數據結構存儲配置項對應的參數 設定配置項在nginx.conf中出現時的限制條件與回調方法 實現2中的回調方法,或者使用nginx框架預設的14個回調方法 合並不同級別的配置塊中出現的同名配置

分配用於保存配置參數的數據結構

創建結構體,包含感興趣的參數,以14種預設配置項的解析為例
這裡寫圖片描述
使用回調函數將自定義的結構體傳遞給nginx
這裡寫圖片描述

設定配置項的解析方式

ngx_command_t

使用14種預設方法解析配置項

這裡寫圖片描述
這裡寫圖片描述
這裡寫圖片描述

ngx_conf_set_flag_slot

這裡寫圖片描述

ngx_conf_set_str_slot

這裡寫圖片描述

ngx_conf_set_str_array_slot

這裡寫圖片描述

ngx_conf_set_keyval_slot

這裡寫圖片描述

其他類似

自定義配置項處理方法

首先定義配置項處理方法
static char* ngx_conf_set_myconfig(ngx_conf_t *cf,ngx_command_t *cmd,void *conf) 接下來定義ngx_command_t 結構體

合並配置項

這裡寫圖片描述

http配置模型

通過ngx_http_conf_ctx_t結構保存了所有http模塊的配置數據結構的入口。

解析http配置的流程

這裡寫圖片描述

http匹配模型的內存布局

這裡寫圖片描述

如何合並配置項

error日志的用法

請求的上下文

上下文與全異步Web服務器的關系

需要局部來維護

Copyright © Linux教程網 All Rights Reserved