Giter VIP home page Giter VIP logo

analyse-plugin-lua's Introduction

BotSonar OpenResty 插件使用说明

  • 简介

    • 该插件用于整合在 OpenResty 或者安装了 lua 模块 的 Nginx 反向代理中,用于收集流量的 Web 端信息以提供给 GCloud 组件进行智能判断。
  • 目录结构

    • GNodePlugin
      • GNode
        • plugin.lua
      • README.md
  • 安装、整合及使用

    • 依赖:

    • 安装:

      • 把 GNode 目录完整的拷贝到/usr/local/openresty/lualib目录下,即 plugin.lua的绝对路径为/usr/local/openresty/lualib/GNode/plugin.lua。(如果自定义了 OpenResty 的安装目录,则需根据情况调整为(OpenResty 安装路径)/lualib/GNode)
    • 整合:

      • 修改 OpenResty 的配置文件,在需要防护的 location 块中添加如下代码以调用该插件:

        access_by_lua_block {
          local plugin = require "GNode.plugin"
          plugin.run()
        }

        示例:

        server {
            listen 80;
            listen 443 ssl;
            ssl_certificate Crt/GNodeCA.crt;
            ssl_certificate_key Crt/GNodeCA.key;
          
            server_name test.com;
          
            error_log  logs/error.log  info;
        
            default_type text/html;
            client_body_buffer_size 256k;
        
            location / {
              access_by_lua_block {
                local plugin = require "GNode.plugin"
                plugin.run()
              }
              proxy_pass http://upstream1;
            }
        }
    • 使用:

      • 整合完插件之后重启 OpenResty 即可。插件正常工作的情况下,反代之后的请求(即 Web 服务器实际收到的请求)头部会携带X-Botsonar-Information字段,其值即为需要发送给 GCloud 判断接口的数据,字符串类型。如:

        image-20190418174610816

        此时可以在服务端取出此字段发送到指定接口并获取判断结果。

      • 错误提示:如果由于某些原因插件运行出错,反代的原始功能不会受到任何影响,但是反代之后的请求头部中不会出现X-Botsonar-Information字段,同时OpenResty 的 error.log(或者用户指定的错误日志输出)中会记录错误消息及原因,如:

        image-20190418175944799

    • 注意事项:

      • 注意涉及到的 OpenResty 的安装目录要根据实际情况进行修改
      • 本插件暂不支持 HTTP/2 协议

analyse-plugin-lua's People

Contributors

bothacker007 avatar smileboywtu avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.