• 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

     

     

     

  • 相关阅读:
    Defcon 23最新开源工具NetRipper代码分析与利用
    如何确定恶意软件是否在自己的电脑中执行过?
    Meteor ToDo App实例
    Meteor在手机上运行
    Meteor部
    Meteor结构
    Meteor package.js
    Meteor Assets资源
    Meteor计时器
    C#与Java对比学习:类型判断、类与接口继承、代码规范与编码习惯、常量定义
  • 原文地址:https://www.cnblogs.com/itcomputer/p/7375193.html
Copyright © 2020-2023  润新知