Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CloudProviders ¶
type Config ¶
type Config struct { Log yeoman.LogConfig `json:"log"` HTTP HTTPConfig `json:"http"` HTTPS HTTPSConfig `json:"https"` ProviderRegistries []yeoman.ProviderRegistry `json:"providerRegistries"` Subnets []string `json:"subnets"` }
type HTTPConfig ¶
type HTTPConfig struct {
Port int `json:"port"`
}
type HTTPSConfig ¶
type Registry ¶
type Registry struct { // Services maps hostnames to one of the following: // // * IPs with optional healthcheck paths, OR Services map[string]*backend `json:"services"` // Subnets restricts internal API access to specific prefixes, which // should all be on a private LAN. Subnets []string `json:"subnets,omitempty"` }
Registry maps hosts to backends with other helpful info, such as healthchecks.
type ReverseProxy ¶
type ReverseProxy struct {
// contains filtered or unexported fields
}
ReverseProxy maps frontend hosts to backends. It will automatically check the `/health` path of backend servers periodically and removes dead backends from rotation until health checks pass.
func New ¶
func New( ctx context.Context, log *slog.Logger, terra CloudProviders, config Config, autocertManager *autocert.Manager, timeout time.Duration, ) (*ReverseProxy, error)
New ReverseProxy from a given Registry.
func (*ReverseProxy) CheckHealth ¶
func (r *ReverseProxy) CheckHealth() error
CheckHealth of backend servers in the registry concurrently, and update the registry so requests are only routed to healthy servers.
func (*ReverseProxy) RedirectHTTPHandler ¶
func (rp *ReverseProxy) RedirectHTTPHandler() (http.Handler, error)
RedirectHTTPHandler redirects http requests to use the API if the request originated from the whitelisted subnet. In all other GET and HEAD requests, this handler redirects to HTTPS. For POST, PUT, etc. this handler throws an error letting the client know to use HTTPS.
func (*ReverseProxy) ServeHTTP ¶
func (r *ReverseProxy) ServeHTTP(w http.ResponseWriter, req *http.Request)
func (*ReverseProxy) UpdateRegistry ¶
func (r *ReverseProxy) UpdateRegistry(reg *Registry)
UpdateRegistry for the reverse proxy with new frontends, backends, and health checks.