Skip to content

Getting started

The gateway is configured with one YAML file. Everything reusable is defined once under Rules, then referenced by name from the scope that needs it. Pick how you run it.

  1. Pull the image.

    Terminal window
    docker pull nocleye/api-gateway:v0.6.0-beta
  2. Write a config. One backend, one route, and a rate limit bound to the route. Callers are identified by IP, there is no default, so the route names a client ID rule. Save it as gateway.yaml in the current directory. The backend address points at a service on your host.

    gateway.yaml
    ApiVersion: v1Beta
    Rules:
    ClientIDRules:
    by-ip:
    Modes: [IP]
    UsageControlRules:
    per-minute:
    RequestCount: 60
    WindowTime: 1m
    ServerConfigs:
    my-api:
    URL: "http://host.docker.internal:9090"
    ServerRoutes:
    api:
    TargetServer: my-api
    MatchOptions:
    PathPattern: /api
    ClientIDRule: by-ip
    UsageControlRules: [per-minute]

    A request to /api/users is forwarded to http://host.docker.internal:9090/api/users, and each IP address gets 60 requests per minute.

  3. Check it. check reports errors and warnings without starting the gateway. See the check reference for every message.

    Terminal window
    docker run --rm \
    -v "$PWD/gateway.yaml:/etc/nocleye-beta/gateway/gateway.yaml:ro" \
    -e GATEWAY_CONFIG_PATH=gateway.yaml \
    nocleye/api-gateway:v0.6.0-beta check
  4. Run it. --add-host lets the container reach your host on Linux. Every flag has an environment variable, see Command line.

    Terminal window
    docker run --rm -p 8080:8080 \
    --add-host=host.docker.internal:host-gateway \
    -v "$PWD/gateway.yaml:/etc/nocleye-beta/gateway/gateway.yaml:ro" \
    -e GATEWAY_CONFIG_PATH=gateway.yaml \
    nocleye/api-gateway:v0.6.0-beta gateway