Caltech Library logo
skip to main content

NAME

reverse-proxy - Forward requests to backend services

SYNOPSIS

[reverse_proxy] PREFIX = TARGET_URL

DESCRIPTION

Forward HTTP requests matching URL prefixes to other backend services. Useful for serving static websites while proxying API requests.

CONFIGURATION

[reverse_proxy]
"/api/" = "http://localhost:9000/"
"/auth/" = "http://localhost:9001/"

PATH HANDLING

Prefix is stripped before forwarding:

PREFIX RULES

VALIDATION

EXAMPLE: Static Website with Dynamic API

htdocs = "./public"

[http]
port = "8000"

[reverse_proxy]
"/api/" = "http://localhost:9000/"

Result: - / -> serves ./public/index.html - /api/users -> proxied to http://localhost:9000/users

MULTIPLE BACKENDS

[reverse_proxy]
"/api/" = "http://api-service:9000/"
"/auth/" = "http://auth-service:9001/"
"/images/" = "http://image-service:9002/"

HTTPS BACKENDS

[reverse_proxy]
"/api/" = "https://api.example.com/"

TROUBLESHOOTING

Backend Connection Refused: - Verify backend service is running - Check backend is listening on correct host/port - Ensure backend is accessible from webserver server

SEE ALSO

config-file, static-website, tls