玩玩 Nginx 2-----给Nginx添加第三方模块(动态更新upstream)
接上一篇,我们在初始化安装的时候添加了nginx_lua模块,然后了解到nginx不可以动态加载模块,所以当你安装第三方模块的时候需要覆盖nginx文件.接下来一起看看如何安装nginx第三模块吧!
1.我们先看看 目前nginx的配置
[root@localhost src]# cd /usr/local/nginx/ [root@localhost nginx]# ./sbin/nginx -V nginx version: nginx/1.8.0 built by gcc 4.8.5 20150623 (Red Hat 4.8.5-11) (GCC) configure arguments: --prefix=/usr/local/nginx --add-module=/usr/local/src/ngx_devel_kit-0.2.19 --add-module=/usr/local/src/lua-nginx-module-0.9.13 [root@localhost nginx]#
2.今天我们以一款动态配置upstream的模块为例子 (lua-upstream-nginx-module) https://github.com/yzprofile/ngx_http_dyups_module
[root@localhost src]# wget https://github.com/yzprofile/ngx_http_dyups_module/archive/master.tar.gz \ > -O ngx_http_dyups_module-master.tar.gz
3.解压,编译
[root@localhost src]# tar -zvxf ngx_http_dyups_module-master.tar.gz [root@localhost src]# cd nginx-1.8.0 [root@localhost nginx-1.8.0]# ./configure --prefix=/usr/local/nginx --add-module=/usr/local/src/ngx_devel_kit-0.2.19 --add-module=/usr/local/src/lua-nginx-module-0.9.13 --add-module=/usr/local/src/ngx_http_dyups_module-master [root@localhost src]# make
4.然后覆盖nginx文件并重新开启nginx
[root@localhost nginx-1.8.0]# /usr/local/nginx/sbin/nginx -s stop [root@localhost nginx-1.8.0]# cp objs/nginx /usr/local/nginx/sbin/nginx cp:是否覆盖"/usr/local/nginx/sbin/nginx"? y [root@localhost nginx-1.8.0]# /usr/local/nginx/sbin/nginx
5.测试下原有lua模块 正常
[root@localhost nginx]# curl -d "server 127.0.0.1:801;server 127.0.0.1:802;" 127.0.0.1:81/upstream/ttlsa3
[root@localhost nginx]# curl 127.0.0.1:81/detail
ttlsa1
server 127.0.0.1:801 weight=1 max_fails=1 fail_timeout=10 backup=0 down=0
ttlsa12
server 127.0.0.1:802 weight=1 max_fails=1 fail_timeout=10 backup=0 down=0
ttlsa3
server 127.0.0.1:801 weight=1 max_fails=1 fail_timeout=10 backup=0 down=0
server 127.0.0.1:802 weight=1 max_fails=1 fail_timeout=10 backup=0 down=0
View Code
浏览器下
ok,http的话c#操作肯定很方便,不过据说这家伙不能upstream 持久化,nginx重启后就啥也没有了,接下来还是的看看有没有其他更好的!
目前看nginx资料都是在一些运维的站点比较多,前两篇也是结合http://www.ttlsa.com去看的,网站不错,名字也很棒《运维生产时间》!
- Nginx 动态添加第三方模块
- nginx入门学习—— 在已安装好的nginx上添加nginx_upstream_check_module模块(三)
- nginx利用第三方模块nginx_upstream_check_module来检查后端服务器的健康情况
- 已安装nginx动态添加模块
- Nginx 动态添加模块
- nginx利用第三方模块nginx_upstream_check_module来检查后端服务器的健康情况
- Yum/RPM安装的Nginx如何添加第三方模块(LuaJIT)
- 006_nginx动态upstream和安全检查模块
- nginx安装编译,动态添加模块及其各模块的作用
- Nginx之——为已安装nginx动态添加模块
- nginx 平滑添加第三方模块
- 已安装nginx动态添加模块
- Linux下Nginx的安装、升级及动态添加模块
- 已安装nginx动态添加模块
- nginx利用第三方模块nginx_upstream_check_module来检查后端服务器的健康情况
- 已安装的nginx添加第三方模块
- centos6.5生产环境编译安装nginx-1.11.3并增加第三方模块ngx_cache_purge、nginx_upstream_check、ngx_devel_kit、lua-nginx
- centos6.5生产环境编译安装nginx-1.11.3并增加第三方模块ngx_cache_purge、nginx_upstream_check、ngx_devel_kit、lua-nginx
- nginx利用第三方模块nginx_upstream_check_module来检查后端服务器的健康情况
- 已安装nginx动态添加模块