Skip to content

Configuration Schema

Exhaustive field reference for both runtime and proxy configuration files. See also the conceptual guide for workflows and examples.


Runtime configuration (config.yaml)

yaml
http:
  - 0.0.0.0:80
https:
  - 0.0.0.0:443

metrics:
  - 127.0.0.1:6192

config_dir: "/etc/nylon/config"
acme: "/etc/nylon/acme"

pingora:
  daemon: false
  threads: 4
  work_stealing: true
  grace_period_seconds: 60
  graceful_shutdown_timeout_seconds: 10
  upstream_keepalive_pool_size: 128
  error_log: "/var/log/nylon/error.log"
  pid_file: "/var/run/nylon.pid"
  upgrade_sock: "/tmp/nylon_upgrade.sock"
  user: "nobody"
  group: "nobody"
  ca_file: "/etc/ssl/certs/ca-certificates.crt"

websocket:
  adapter_type: redis  # memory | redis | cluster
  redis:
    host: localhost
    port: 6379
    password: null
    db: 0
    key_prefix: "nylon:ws"

Field reference

FieldTypeRequiredDefaultNotes
http[]stringNo[]HTTP listener addresses (host:port).
https[]stringNo[]HTTPS listeners (requires TLS in proxy config).
metrics[]stringNo[]Reserved for future Prometheus exporter.
config_dirstringNo/etc/nylon/configRoot directory for proxy YAML files.
acmestringNo/etc/nylon/acmeACME storage (certificates + account).
pingoraobjectNo{}Pingora runtime configuration (see below).
websocketobjectNonullWebSocket adapter. Required for redis/cluster.

pingora object

FieldTypeDefaultDescription
daemonboolfalseStart as daemon (Linux).
threadsintCPU cores - 2Worker threads (clamped to ≥1).
work_stealingboolfalseEnable work stealing across threads.
grace_period_secondsint60Grace period before shutdown.
graceful_shutdown_timeout_secondsint10Hard shutdown deadline.
upstream_keepalive_pool_sizeintnullCap for upstream keepalive pool.
error_logstringnullPingora error log path.
pid_filestringnullPID file path.
upgrade_sockstringnullDomain socket for zero-downtime upgrades.
user / groupstringnullDrop privileges after binding ports.
ca_filestringnullCustom CA bundle for upstream TLS.

websocket object (optional)

FieldTypeRequiredDescription
adapter_typestringNomemory, redis, or cluster (default redis).
redisobjectFor redis/clusterConnection details: host, port, password, db, key_prefix.
clusterobjectFor clusterSeed nodes and optional key_prefix.

Proxy configuration (config_dir)

Every YAML file within config_dir is merged. Example scaffold:

yaml
header_selector: x-nylon-proxy

plugins:
  - name: auth
    type: ffi
    file: /opt/nylon/plugins/auth.so
    config:
      issuer: https://auth.example.com

services:
  - name: backend
    service_type: http
    algorithm: round_robin
    endpoints:
      - ip: 10.0.0.1
        port: 3000
    health_check:
      enabled: true
      path: /health
      interval: 5s
      timeout: 2s
      healthy_threshold: 2
      unhealthy_threshold: 3

middleware_groups:
  security:
    - plugin: RequestHeaderModifier
      payload:
        set:
          - name: x-request-id
            value: "${uuid(v7)}"

routes:
  - route:
      type: host
      value: example.com|example.org
    name: main
    tls:
      enabled: true
      redirect: ${host}
    middleware:
      - group: security
    paths:
      - path:
          - /
          - /{*path}
        service:
          name: backend
        methods:
          - GET
          - POST

tls:
  - type: acme
    provider: letsencrypt
    domains:
      - example.com
    acme:
      email: [email protected]

Plugins

FieldTypeRequiredDescription
namestringYesPlugin identifier (unique).
typestringYesCurrently only ffi.
filestringYesShared library path.
configobjectNoArbitrary configuration passed to plugin.

Services

FieldTypeRequiredApplies to
namestringYesAll services.
service_typestringYeshttp, plugin, or static.
algorithmstringNoHTTP services (round_robin, weighted, consistent, random).
endpoints[]objectFor httpEach endpoint requires ip, port, optional weight.
health_checkobjectFor httpSee table below.
pluginobjectFor pluginPlugin invocation (name, entry, optional payload).
staticobjectFor staticroot, index, optional spa.

Health check object

FieldTypeDefaultDescription
enabledboolfalseEnable active health checks.
pathstring/Probe path.
intervalstring10sFrequency (must end with s).
timeoutstring5sProbe timeout (must end with s).
healthy_thresholdint2Successes before healthy.
unhealthy_thresholdint3Failures before unhealthy.

Middleware groups

Dictionary of reusable middleware chains:

yaml
middleware_groups:
  security:
    - plugin: ResponseHeaderModifier
      payload:
        set:
          - name: x-frame-options
            value: "DENY"

Each entry mirrors route-level middleware (group or explicit plugin/entry/payload).

Routes

FieldTypeRequiredNotes
routeobjectYesMatcher definition. type = host or header (requires header_selector). value supports `a
namestringYesUnique route name.
tlsobjectNoenabled, optional redirect.
middleware[]objectNoRoute-level middleware entries.
paths[]objectYesPath matchers (see below).

Path object

FieldTypeRequiredDescription
pathstring or []stringYesPattern(s) for MatchIt router. Supports * and {param}.
serviceobjectYesname (service), optional rewrite.
methods[]stringNoLimit to specific HTTP methods.
middleware[]objectNoPath-specific middleware.

Middleware entry

FieldTypeRequiredDescription
groupstringEitherReference a middleware group.
pluginstringEitherPlugin name to execute.
entrystringIf pluginHandler exported by plugin.
payloadobjectNoArbitrary JSON passed to handler.

TLS entries

FieldTypeRequiredDescription
typestringYescustom or acme.
domains[]stringYesSAN list / hostnames. Must be unique across entries.
cert / keystringFor customPEM files for certificate and private key.
chain[]stringNoAdditional chain PEMs.
providerstringFor acmeACME provider (e.g. letsencrypt).
acmeobjectFor acmeemail, optional directory_url, staging, eab_kid, eab_hmac_key.

Template expressions

Expressions can appear inside payloads to reference request context.

FunctionDescriptionExample
${header(name)}Request header (case-sensitive).${header(user-agent)}
${query(name[, default])}Query string value.${query(version, 'v1')}
${cookie(name[, default])}Cookie lookup.${cookie(session_id)}
${param(name[, default])}Route/path parameter.${param(account_id)}
${request(field)}Request metadata (client_ip, host, method, path, scheme, tls).${request(method)}
${env(VAR)}Environment variable.${env(SERVICE_NAME)}
${uuid(v4|v7)}Generate UUID string.${uuid(v7)}
${timestamp()}RFC3339 timestamp with millisecond precision.${timestamp()}
${or(a, b, …)}First non-empty argument.${or(env(NAME), 'default')}
${eq(a, b[, value])}Returns value (or a) if a == b.${eq(request(method), 'GET', 'cacheable')}
${neq(a, b[, value])}Returns value (or a) if a != b.${neq(request(scheme), 'https', 'insecure')}
${concat(values…)}Concatenate arguments.${concat(header(host), '-', uuid(v4))}
${upper(value)} / ${lower(value)}Case conversion.${upper(param(region))}
${len(value)}String length.${len(header(user-agent))}
${if_cond(condition, then, else)}Conditional evaluation (truthy when non-empty).${if_cond(request(tls), 'https', 'http')}

Released under the MIT License.