Configuration Examples

Real-world origin configuration examples

Overview

Real-world configuration examples for common SBproxy use cases.

Basic Reverse Proxy

proxy:
  http_bind_port: 8080

origins:
  "app.example.com":
    action:
      type: proxy
      url: https://test.sbproxy.dev
      strip_base_path: true

Test it:

curl -H "Host: app.example.com" http://localhost:8080/

API Gateway with Rate Limiting

proxy:
  http_bind_port: 8080

origins:
  "api.example.com":
    action:
      type: proxy
      url: https://test.sbproxy.dev
    policies:
      - type: rate_limiting
        requests_per_minute: 100
        algorithm: sliding_window
      - type: security_headers
        hsts:
          max_age: 31536000
    request_modifiers:
      headers:
        set:
          X-Real-IP: "{{request.remote_addr}}"

Test it:

curl -H "Host: api.example.com" http://localhost:8080/

Microservices Router

proxy:
  http_bind_port: 8080

origins:
  "api.example.com":
    forward_rules:
      - hostname: users-config
        rules:
          - path:
              prefix: /api/users
      - hostname: orders-config
        rules:
          - path:
              prefix: /api/orders
    action:
      type: static
      status_code: 404
      json_body:
        error: Route not found

Test it:

curl -H "Host: api.example.com" http://localhost:8080/