Skip to content

GatewayConfig

thiagobustamante edited this page Jun 21, 2017 · 30 revisions

This is the Gateway config descriptor. It can be configured inside tree-gateway Config File or passed directly to the SDK.gateway.updateConfig() method.

It support the following properties:

Property Type Description Required
protocol ProtocolConfig The gateway protocol configuration. true
underProxy boolean If we are behind a reverse proxy (Heroku, Bluemix, AWS if you use an ELB, custom Nginx setup, etc). false
logger LoggerConfig Configurations for gateway logger. false
accessLogger AccessLoggerConfig Configurations for gateway access logger. false
statsConfig StatsConfig Configurations for gateway stats. false
monitor MonitorConfig[] Create monitors to actively collect some stats. false
admin AdminConfig If provided, Configure the admin service for the gateway. false
cors CorsConfig Configure default cors support for API requests. It can be configured also in the API configuration. false
timeout string or number Configure a timeout for the gateway http.Server. You can inform the amount of milisencods, or use a human-interval string. Defaults to 'one minute'. false
filter MiddlewareConfig[] An array of installed Filter middlewares to be executed, in order, by the request pipeline. false

Example:

{
    "gateway": {
        "protocol": {
            "http": {
                "listenPort": 8000
            }
        },
        "admin": {
            "protocol": {
                "http": {
                    "listenPort": 8001
                }
            },
            "accessLogger": {
                "msg": "HTTP {{req.method}} - {{res.statusCode}} - {{req.url}} ({{res.responseTime}}ms) ",
                "console": {
                    "timestamp": true,
                    "colorize": true
                }
            },
            "userService": {
                "jwtSecret": "secret"
            }
        },
        "logger": {
            "level": "info",
            "console": {
                "colorize": true
            },
            "file": {
                "timestamp": true,
                "outputDir": "./logs",
                "json": false, 
                "prettyPrint": true 
            }
        },
        "monitor": [
            {
                "name": "cpu",
                "statsConfig": {
                    "granularity": {
                        "duration": "1 minute",
                        "ttl": "2 days"
                    }
                }            
            }
        ],
        "filter": [{
            "name": "ipFilter",
            "options": {
                "blacklist": ["10.100.*.*"]
            }
        }]        
    }
} 

or

gateway:
  protocol:
    http:
      listenPort: 8000
  admin:
    protocol:
      http:
        listenPort: 8001
    accessLogger:
      msg: 'HTTP {{req.method}} - {{res.statusCode}} - {{req.url}} ({{res.responseTime}}ms)'
      console:
        timestamp: true
        colorize: true
    userService:
      jwtSecret: secret
  logger:
    level: info
    console:
      colorize: true
    file:
      timestamp: true
      outputDir: "./logs"
      json: false
      prettyPrint: true
  monitor:
  - name: cpu
    statsConfig:
      granularity:
        duration: 1 minute
        ttl: 2 days
  filter:
    - name: ipFilter 
      options: 
        blacklist: 
          - "10.100.*.*"
Clone this wiki locally