在CentOS 6.9 x86_64的nginx 1.12.2上开启标准模块ngx_http_auth_request_module实录
生活随笔
收集整理的這篇文章主要介紹了
在CentOS 6.9 x86_64的nginx 1.12.2上开启标准模块ngx_http_auth_request_module实录
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
ngx_http_auth_request_module是是nginx的一個驗證模塊,它允許您的nginx通過發送請求到后端服務器(一般是應用服務器,例如tomcat,或者php等)進行請求, 并且根據請求決定是驗證通過或者不通過。后端返回200 驗證通過, 后端返回401或者403驗證不通過。
該模塊默認可以開啟,可以在configure時使用--with-http_auth_request_module選項來開啟
下面的配置在原有模塊的基礎上追加方式進行
cd nginx-1.12.2
./configure --with-http_ssl_module \
--with-pcre=/usr/local/src/pcre-8.41 \
--with-zlib=/usr/local/src/zlib-1.2.11 \
--with-openssl=/usr/local/src/openssl-1.1.0g \
--with-http_stub_status_module \
--with-http_auth_request_module \
--add-module=/usr/local/src/ngx_cache_purge \
--add-module=/usr/local/src/ngx_req_status \
--add-module=/usr/local/src/echo-nginx-module \
--add-module=/usr/local/src/ngx_devel_kit-0.3.0 \
--add-module=/usr/local/src/set-misc-nginx-module-0.31
make
make install
該模塊默認可以開啟,可以在configure時使用--with-http_auth_request_module選項來開啟
下面的配置在原有模塊的基礎上追加方式進行
cd nginx-1.12.2
./configure --with-http_ssl_module \
--with-pcre=/usr/local/src/pcre-8.41 \
--with-zlib=/usr/local/src/zlib-1.2.11 \
--with-openssl=/usr/local/src/openssl-1.1.0g \
--with-http_stub_status_module \
--with-http_auth_request_module \
--add-module=/usr/local/src/ngx_cache_purge \
--add-module=/usr/local/src/ngx_req_status \
--add-module=/usr/local/src/echo-nginx-module \
--add-module=/usr/local/src/ngx_devel_kit-0.3.0 \
--add-module=/usr/local/src/set-misc-nginx-module-0.31
make
make install
測試
location /main2 {set $var main;auth_request /sub;echo "main: $var";}location /sub {set $var sub;echo "sub: $var";}curl -v 'http://localhost:8082/main2'
gx_auth_request模塊發起的“子請求”確實是與其“父請求”共享一套 Nginx 變量的值容器。這違背了主請求”以及各個“子請求”都擁有不同的變量 的值容器副本的原則,會經常導致不少難于調試的詭異bug。諸如此類的因共享而導致的不好的“副作用”,讓包括 ngx_echo,ngx_lua,以及 ngx_srcache 在內的許多第三方模塊都選擇了禁用父子請求間的變量共享。
參考文獻
[1].http://nginx.org/en/docs/http/ngx_http_auth_request_module.html
[2].http://www.ttlsa.com/nginx/nginx-var-5/
[3].http://www.iigrowing.cn/nginx_hou_duan_yan_zheng_mo_kuai_ngx_http_auth_request_module.html
總結
以上是生活随笔為你收集整理的在CentOS 6.9 x86_64的nginx 1.12.2上开启标准模块ngx_http_auth_request_module实录的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 在CentOS 6.9 x86_64的n
- 下一篇: 在Ubuntu 16.4.3 LTS x