• 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

     

     

     

  • 相关阅读:
    温故知新 将Date和String类型相互转换
    温故知新 线程
    温故知新 数组
    温故知新 集合
    温故知新 流(字节流与字符流)
    温故知新 jdbc 数据库调取封装
    Reds 持久化 高并发 高可用
    批量修改文件后缀名
    scala之旅-核心语言特性【高阶函数】(十)
    scala之旅-核心语言特性【使用混入组合类】(九)
  • 原文地址:https://www.cnblogs.com/itcomputer/p/7375193.html
Copyright © 2020-2023  润新知