---
title: Configuration
description: Config reference, YAML example, and options for Gateway
deprecated: true
supersededBy: ['/docs/bastion']
---

## YAML Configuration Example

```yaml title="config.yaml"
extensions:
  gateway:
    enabled: true
    basePath: ""

    timeouts:
      connect: "10s"
      read: "30s"
      write: "30s"
      idle: "90s"

    retry:
      enabled: true
      maxAttempts: 3
      initialDelay: "100ms"
      maxDelay: "5s"
      jitter: true

    circuitBreaker:
      enabled: true
      failureThreshold: 5
      failureWindow: "60s"
      resetTimeout: "30s"

    healthCheck:
      enabled: true
      interval: "10s"
      path: "/_/health"
      failureThreshold: 3
      successThreshold: 2

    loadBalancing:
      strategy: "round_robin"       # round_robin, weighted, random, least_connections, consistent_hash

    discovery:
      enabled: true
      pollInterval: "30s"
      watchMode: true
      autoPrefix: true
      prefixTemplate: "/{{.ServiceName}}"
      stripPrefix: true

    dashboard:
      enabled: true
      basePath: "/gateway"
      realtime: true

    openAPI:
      enabled: true
      path: "/gateway/openapi.json"
      uiPath: "/gateway/docs"

    routes:
      - path: "/api/users/*"
        target: "http://users-service:8080"
        methods: ["GET", "POST", "PUT", "DELETE"]
        stripPrefix: true
```

The extension loads config from `extensions.gateway` first, falling back to `gateway`.

## Programmatic Configuration

```go
ext := gateway.NewExtension(
    // Enable FARP discovery with watch mode.
    gateway.WithDiscoveryEnabled(true),
    gateway.WithDiscoveryWatchMode(true),
    gateway.WithDiscoveryAutoPrefix(true),
    gateway.WithDiscoveryStripPrefix(true),

    // Dashboard and load balancing.
    gateway.WithDashboard(gateway.DashboardConfig{Enabled: true}),
    gateway.WithLoadBalancing(gateway.LoadBalancingConfig{
        Strategy: gateway.LBRoundRobin,
    }),
    gateway.WithCircuitBreaker(gateway.CircuitBreakerConfig{
        Enabled:          true,
        FailureThreshold: 5,
        FailureWindow:    60 * time.Second,
        ResetTimeout:     30 * time.Second,
    }),
    gateway.WithHealthCheck(gateway.HealthCheckConfig{
        Enabled:  true,
        Interval: 10 * time.Second,
        Path:     "/_/health",
    }),
)
```

## Key Config Sections

### Timeouts

| Field | Default | Description |
|---|---|---|
| `Connect` | `10s` | Upstream connection timeout |
| `Read` | `30s` | Response read timeout |
| `Write` | `30s` | Request write timeout |
| `Idle` | `90s` | Idle connection timeout |

### Retry

| Field | Default | Description |
|---|---|---|
| `Enabled` | `true` | Enable retries |
| `MaxAttempts` | `3` | Maximum retry attempts |
| `InitialDelay` | `100ms` | Initial backoff delay |
| `MaxDelay` | `5s` | Maximum backoff delay |
| `Jitter` | `true` | Add random jitter |

### Circuit Breaker

| Field | Default | Description |
|---|---|---|
| `Enabled` | `true` | Enable circuit breakers |
| `FailureThreshold` | `5` | Failures before opening |
| `FailureWindow` | `60s` | Window for counting failures |
| `ResetTimeout` | `30s` | Time before half-open |

### Discovery

| Field | Default | Description |
|---|---|---|
| `Enabled` | `true` | Enable FARP auto-discovery |
| `PollInterval` | `30s` | Discovery poll interval |
| `WatchMode` | `true` | Watch for service changes instead of polling |
| `ServiceFilters` | `[]` | Service filter rules (include/exclude by name, tags, metadata) |
| `AutoPrefix` | `true` | Auto-prefix routes with service name |
| `PrefixTemplate` | `"/{{.ServiceName}}"` | Route prefix template (Go text/template syntax) |
| `StripPrefix` | `true` | Strip prefix before forwarding to upstream |

### Service Filters

| Field | Description |
|---|---|
| `IncludeNames` | Only include services matching these names (supports `*` wildcards) |
| `ExcludeNames` | Exclude services matching these names (supports `*` wildcards) |
| `IncludeTags` | Only include services that have all of these tags |
| `ExcludeTags` | Exclude services that have any of these tags |
| `RequireMetadata` | Require specific key-value pairs in service metadata |

### Discovery Config Options

| Option | Description |
|---|---|
| `WithDiscovery(cfg)` | Set the full discovery configuration |
| `WithDiscoveryEnabled(bool)` | Enable or disable FARP discovery |
| `WithDiscoveryPollInterval(d)` | Set the polling interval |
| `WithDiscoveryWatchMode(bool)` | Use watch mode instead of polling |
| `WithDiscoveryAutoPrefix(bool)` | Auto-generate path prefixes from service names |
| `WithDiscoveryPrefixTemplate(tmpl)` | Set the prefix template |
| `WithDiscoveryStripPrefix(bool)` | Strip prefix before proxying |
| `WithDiscoveryServiceFilters(filters...)` | Set service filters |

### Dashboard

| Field | Default | Description |
|---|---|---|
| `Enabled` | `true` | Enable admin dashboard |
| `BasePath` | `"/gateway"` | Dashboard URL base path |
| `Realtime` | `true` | Enable WebSocket updates |
