Nginx学习——http配置项解析编程 配置config 在nginx_http_mytest_module.c中定义mytest模块,使用预设方法解析test_flag,test_str,test_num配置项,使用自己定义配置项处理方法解析mytest项。 在ngx.conf中http以下默认server中增加例如以下配置项 启动nginx 结果例如以下


http配置项解析编程


 



ngx_addon_name=ngx_http_mytest_module


HTTP_MODULES="$HTTP_MODULES ngx_http_mytest_module"


NGX_ADDON_SRCS="$NGX_ADDON_SRCS $ngx_addon_dir/ngx_http_mytest_module.c"


nginx_http_mytest_module.c中定义mytest模块,使用预设方法解析test_flagtest_str,test_num配置项,使用自己定义配置项处理方法解析mytest项。






ngx.confhttp以下默认server中增加例如以下配置项


location /test{


               test_flag on;


               test_str "helloworld";


               test_num 88;


               mytest"hello" 88;


        }


启动nginx


./configure --add-module=/home/chen123/nginx/exp3


make


make install


sudo /usr/local/nginx/sbin/nginx


 


结果例如以下

Nginx学习——http配置项解析编程
配置config
在nginx_http_mytest_module.c中定义mytest模块,使用预设方法解析test_flag,test_str,test_num配置项,使用自己定义配置项处理方法解析mytest项。
在ngx.conf中http以下默认server中增加例如以下配置项
启动nginx
结果例如以下