006_nginx动态upstream和安全检查模块

一、参考Tengine   http://tengine.taobao.org/document_cn/http_dyups_cn.html

ngx_http_dyups_module

Description

This module can be used to update your upstream-list without reloadding Nginx.

TODO:

It can not work with common `nginx_upstream_check_module`.

Compilation

The module is not compiled into Tengine by default. It can be enabled with '--with-http_dyups_module'
configuration parameter, and enabled lua support with '--with-http_dyups_lua_api'.
But it can not be compiled as a '.so'.

二、配置
在http块中引用如下的配置=>
http { dyups_upstream_conf upstream/ngconf_dyups.conf; include upstream/ngconf_dyups.conf; #假如已经include进来的话就不需要include了;eg: include upstream/*.conf; } cat upstream/ngconf_dyups.conf server { listen 8866; location / { dyups_interface; #you should add the directive dyups_interface into your config file to active this feature } }
三、restful interface常用操作。
<1>curl -H "host: dyhost" 127.0.0.1:8866/detail        #获取所有的upstream和他们的后端server
xxx-svr-backend
server 10.103.101.169:8080
server 10.103.104.207:8080

xxx-admin-backend
server 10.103.105.81:9001
server 10.103.105.80:9001

xxx-admin.alta.jyall.me.alta1-hg-xxx-admin
server 10.103.105.81:9001
server 10.103.105.80:9001

xxx.alta.jyall.me.alta1-hg-xxx-proxy
server 10.103.101.169:8080
server 10.103.104.207:8080

<2>curl -H "host: dyhost" 127.0.0.1:8866/list      #获取upstream的名称列表

xxx-svr-backend
xxx-admin-backend
xxx-admin.alta.jyall.me.alta1-hg-xxx-admin
xxx.alta.jyall.me.alta1-hg-xxx-proxy

<3>curl -H "host: dyhost" 127.0.0.1:8866/upstream/xxx-svr-backend        #根据upstream的名字找出它后端的server列表

server 10.103.101.169:8080
server 10.103.104.207:8080

<4>添加或更新一个upstream

curl -d "server 127.0.0.1:8089;server 127.0.0.1:8088;" 127.0.0.1:8866/upstream/arun_test        

curl -d "server 127.0.0.1:9000;server 127.0.0.1:8088;" 127.0.0.1:8866/upstream/arun_test

curl -H "host: dyhost" 127.0.0.1:8866/upstream/arun_test

server 127.0.0.1:9000
server 127.0.0.1:8088

<5>curl 127.0.0.1:8866/detail

arun_test
server 127.0.0.1:9000
server 127.0.0.1:8088

<6>curl -i -X DELETE 127.0.0.1:8866/upstream/arun_test    #动态删除upstream

HTTP/1.1 200 OK
Date: Wed, 16 Aug 2017 12:05:58 GMT
Content-Length: 7
Connection: keep-alive

success

curl 127.0.0.1:8866/detail再次查看"arun_test"的upstream已经被删除了。

-------------------------------------------------------------------------ngx_http_upstream_check_module--------------------------------------------------------------------------------

四、upstream检查模块。

 

http://tengine.taobao.org/document_cn/http_upstream_check_cn.html

 

 

 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值