我是靠谱客的博主 无情心情,这篇文章主要介绍在CentOS 6.9 x86_64的nginx 1.12.2上安装第三方模块set-misc-nginx-module实录,现在分享给大家,希望可以做个参考。

set-misc-nginx-module模块是标准的HttpRewriteModule指令的扩展,提供更多的功能,如URI转义与非转义、JSON引述、Hexadecimal/MD5/SHA1/Base32/Base64编码与解码、随机数等等。在后面的应用中,都将会接触使用到这个模块的。该模块是由章亦春先生开发的,他开发的其他模块应用也会使用到这个模块的。充分使用nginx非阻塞模式,对性能上有极大的提高,我个人认为很有必要去弄懂弄透nginx,通过自己去动手动脑用实例来加以验证,不断的对模块参数命令加以理解,在实际环境中应用自如。
这两个模块的主页分别是
标准模块ngx_http_rewrite_module
http://nginx.org/en/docs/http/ngx_http_rewrite_module.html
第三方模块set-misc-nginx-module
ngx_set_misc - Various set_xxx directives added to nginx's rewrite module (md5/sha1, sql/json quoting, and many more)
https://github.com/openresty/set-misc-nginx-module


下载源码
cd /usr/local/src
wget https://github.com/openresty/set-misc-nginx-module/archive/v0.31.tar.gz
wget https://github.com/simpl/ngx_devel_kit/archive/v0.3.0.tar.gz
tar zxvf v0.31.tar.gz
tar zxvf v0.3.0.tar.gz


编译安装
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
--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
注意这里set-misc-nginx-module依赖ngx_devel_kit模块,且--add-module=ngx_devel_kit一定要早于--add-module=set-misc-nginx-module


配置

        location /test {
            echo "uri = $uri";
            echo "request_uri = $request_uri";
            echo "name: $arg_name";
            echo "class: $arg_class";
            set_unescape_uri $name $arg_name;
            set_unescape_uri $class $arg_class;
            echo "name: $name";
            echo "class: $class";
        }

更完整的nginx.conf配置参见
https://github.com/taoyunxing/github_test/blob/master/nginx.conf

测试

curl -v 'http://localhost:8082/test'
curl 'http://localhost:8082/test?a=3&b=4'
curl 'http://localhost:8082/test/hello%20world?a=3&b=4'


curl 'http://localhost:8082/test?name=Tom&class=3'
curl 'http://localhost:8082/test?name=hello%20world&class=9'
curl 'http://localhost:8082/test?NAME=Marry'

curl 'http://localhost:8082/test?Name=Jimmy'


curl 'http://localhost:8082/test?name=hello%20world&class=9'


更复杂的指令待后续继续补充


参考文献
[1].https://github.com/openresty/set-misc-nginx-module
[2].http://www.ttlsa.com/nginx/nginx_set-misc-nginx-module-module-description/
[3].https://github.com/openresty/set-misc-nginx-module#installation

[4].http://www.ttlsa.com/nginx/nginx-var-2/


最后

以上就是无情心情最近收集整理的关于在CentOS 6.9 x86_64的nginx 1.12.2上安装第三方模块set-misc-nginx-module实录的全部内容,更多相关在CentOS内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(47)

评论列表共有 0 条评论

立即
投稿
返回
顶部