Coder Social home page Coder Social logo

gateway's Introduction

Gateway

Version License

Overview

  • 基于netty的nio服务网关
  1. 支持http协议
  2. 支持https协议
  3. 支持cors协议
  4. 支持基于本地令牌桶的限流
  5. 相对独立的线程池
  6. 负载均衡采用 RandomLoadBalance 随机负载均衡算法

Usage

  • 启动jar包

    java -jar gateway.jar -c /root/config.json
    1. -v 显示版本号
    2. -c 指定json配置文件
    3. -h 显示帮助中心
  • config.json

    {
      "http": {
        "port": 8080,
        "redirectHttps": false
      },
      "https": {
        "enable": false,
        "port": 8081,
        "keyPwd": "123456",
        "keyPath": "/Users/chenweidong/workspace/gateway/ssl/cwd.keystore"
      },
      "threadPool": {
        "core": 150,
        "max": 200,
        "timeout": 5000
      },
      "mapping": {
        "localhost:8080": [
          {
            "url": "123.125.115.110:80",
            "weight": 200
          },
          {
            "url": "220.181.57.216:80",
            "weight": 100
          }
        ]
      },
      "cors": {
        "enable": true,
        "whiteList": []
      },
      "flowLimits": {
        "enable": true,
        "timeout": 500,
        "rate": 2000000000,
        "maxSize": 200
      }
    }
    1. http: http相关配置
      1. port: 端口号
      2. redirectHttps: 是否重定向至https
    2. https: https相关配置
      1. enable: 是否开启
      2. port: 端口号
      3. keyPwd: 证书密码
      4. keyPath: 证书路径
    3. threadPool: 单个反射配置的线程池配置
      1. core: 核心线程数量
      2. max: 最大线程数量
      3. timeout: 超时时间
    4. mapping: 映射配置,每个host对应多个反向代理地址
      1. url: 反向代理地址
      2. weight: 权重
    5. cors: 跨域相关配置
      1. enable: 是否开启跨域
      2. whiteList: 跨域白名单,列表为空且开启跨域情况下为允许全部origin跨域请求
    6. flowLimits: 限流配置
      1. enable: 是否开启限流
      2. timeout: 请求超时时间,单位ms
      3. rate: 令牌生产速率,单位ms
      4. maxSize: 令牌桶大小

gateway's People

Contributors

cwdtom avatar

Watchers

James Cloos 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.