Your First Proxy

Working reverse proxy in under 5 minutes

Install SBproxy

brew tap soapbucket/tap && brew install sbproxy

Not on macOS? See the install page for Linux, Docker, and binary downloads.

Create Your Config

Create a file called sb.yml:

proxy:
  http_bind_port: 8080

origins:
  "api.example.com":
    action:
      type: proxy
      url: https://test.sbproxy.dev

Start the Proxy

sbproxy serve -f sb.yml

Send a Request

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

What Just Happened

  • SBproxy listened on port 8080 and matched the Host header to the api.example.com origin.
  • The handler chain ran. No policies were configured, so the request passed straight through.
  • The proxy action forwarded the request to https://test.sbproxy.dev/echo.
  • The upstream response was returned to your terminal.

Add Authentication

Require an API key on every request:

proxy:
  http_bind_port: 8080

origins:
  "api.example.com":
    action:
      type: proxy
      url: https://test.sbproxy.dev
    authentication:
      type: api_key
      api_keys:
        - name: my-app
          key: sk-test-key-123

Restart sbproxy. Now try both:

# Without a key (returns 401)
curl -H "Host: api.example.com" http://localhost:8080/echo

# With a key (returns 200)
curl -H "Host: api.example.com" -H "Authorization: Bearer sk-test-key-123" http://localhost:8080/echo

Add Rate Limiting

Limit each client to 10 requests per minute:

proxy:
  http_bind_port: 8080

origins:
  "api.example.com":
    action:
      type: proxy
      url: https://test.sbproxy.dev
    authentication:
      type: api_key
      api_keys:
        - name: my-app
          key: sk-test-key-123
    policies:
      rate_limiting:
        requests_per_minute: 10

Next Steps