proxy

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 14, 2026 License: MIT Imports: 23 Imported by: 0

Documentation

Overview

Package proxy is an exact-host routing reverse proxy.

Requests are routed only when their normalized full Host header matches a hostname generated from the site's stored hostname identity. The registry is reloaded whenever sites.toml changes, so newly added sites route without a restart. Unknown or bare hosts get a landing page listing every site.

The Host header sent to the backend is rewritten to the backend's own address by default, so dev servers with host allowlists (Vite 5+, Next, Rails host authorization) accept proxied requests. Sites that need the original Host can set preserve_host = true. X-Forwarded-Host/Proto/For are always set from the inbound request.

httputil.ReverseProxy transparently handles HTTP/1.1 Upgrade (websockets), which jigyll live-reload and Vite/Next HMR depend on.

Index

Constants

View Source
const Slug = "__proxy"

Slug is the reserved state key for the background proxy process.

Variables

This section is empty.

Functions

func Accepting

func Accepting(settings config.Settings) bool

Accepting reports whether the active HTTP listener is accepting connections.

func Running

func Running(st *state.State) (bool, int)

Running reports whether the background proxy process is alive, with its pid.

func StartBackground

func StartBackground(settings config.Settings) error

StartBackground launches `servd proxy` detached and records it in state. It is a no-op if the proxy is already running.

func StopBackground

func StopBackground() error

StopBackground signals the background proxy and clears its state entry.

Types

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server is a running proxy instance.

func New

func New(settings config.Settings) *Server

New builds a proxy server and loads the initial routing table.

func (*Server) ListenAndServe

func (s *Server) ListenAndServe() error

ListenAndServe starts the proxy on the active HTTP listener port.

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL