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
Hostheader to theapi.example.comorigin. - The handler chain ran. No policies were configured, so the request passed straight through.
- The
proxyaction forwarded the request tohttps://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
- Load Balancing - distribute traffic across multiple backends
- Path Rules - route different paths to different upstreams
- WAF - block SQL injection, XSS, and other attacks
- Kubernetes Deployment - run SBproxy in production