Documentation ¶
Index ¶
- Constants
- Variables
- func CARootPath() string
- func CertPath() string
- func CreateProxy(targetURL url.URL, vhost string) *httputil.ReverseProxy
- func InitTrustStore() error
- func InstallTrustStore() error
- func MakeCert(host string) (certFile string, keyFile string, err error)
- func StartHello(host string, port int) error
- func UninstallTrustStore() error
- type Client
- func (c *Client) AddBinding(bind string, detach bool)
- func (c *Client) AddBindings(binds []string, detach bool, args []string)
- func (c *Client) IsDaemonRunning() bool
- func (c *Client) RemoveVhost(hostname string, all bool)
- func (c *Client) RunCommand(args []string)
- func (c *Client) Tail(hostname string, follow bool)
- type Daemon
- type LogListener
- type LogRecord
- type LoggedHandler
- func (lh *LoggedHandler) AddVhost(vhost *Vhost)
- func (lh *LoggedHandler) CreateTLSConfig() *tls.Config
- func (lh *LoggedHandler) DumpServers(w io.Writer)
- func (lh *LoggedHandler) GetVhost(host string) *Vhost
- func (lh *LoggedHandler) RemoveVhost(host string)
- func (lh *LoggedHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
- type Vhost
- type VhostMux
Constants ¶
const PONG = "hello from vproxy"
PONG server identifier
Variables ¶
var VERBOSE = false
Controls whether verbose messages should be printed
Functions ¶
func CARootPath ¶
func CARootPath() string
func CreateProxy ¶
func CreateProxy(targetURL url.URL, vhost string) *httputil.ReverseProxy
CreateProxy with custom http.RoundTripper impl. Sets proper host headers using given vhost name.
func InitTrustStore ¶ added in v0.10.1
func InitTrustStore() error
func InstallTrustStore ¶ added in v0.10.1
func InstallTrustStore() error
func StartHello ¶ added in v0.10.1
StartHello world service on the given host/port
This is a simple service which always responds with 'Hello World'. It's mainly here to serve as a simple demo of vproxy's abilities (see readme).
func UninstallTrustStore ¶ added in v0.10.1
func UninstallTrustStore() error
Types ¶
type Client ¶ added in v0.10.1
type Client struct { Addr string // contains filtered or unexported fields }
func (*Client) AddBinding ¶ added in v0.12.1
Add single binding. Blocks when detach=false
func (*Client) AddBindings ¶ added in v0.10.1
func (*Client) IsDaemonRunning ¶ added in v0.10.1
IsDaemonRunning tries to check if a vproxy daemon is already running on the given addr
func (*Client) RemoveVhost ¶ added in v0.10.1
func (*Client) RunCommand ¶ added in v0.12.1
type Daemon ¶ added in v0.4.1
type Daemon struct {
// contains filtered or unexported fields
}
Daemon service which hosts all the virtual reverse proxies
proxy chain: daemon -> mux (LoggedHandler) -> /* -> VhostMux -> Vhost -> ReverseProxy -> upstream service
type LogListener ¶ added in v0.10.1
type LogListener chan string
type LogRecord ¶
type LogRecord struct { http.ResponseWriter // contains filtered or unexported fields }
LogRecord is a thin wrapper around http.ResponseWriter which allows us to capture the number of response bytes written and the http status code.
func (*LogRecord) WriteHeader ¶
WriteHeader wrapper that captures status code
type LoggedHandler ¶ added in v0.6.2
LoggedHandler is an extension of http.ServeMux which multiplexes requests to the vhost backends (via a handler) and logs each request. TODO: replace ServeMux with a proper router (chi?)
func NewLoggedHandler ¶ added in v0.6.2
func NewLoggedHandler(vm *VhostMux) *LoggedHandler
NewLoggedHandler wraps the given handler with a request/response logger
func (*LoggedHandler) AddVhost ¶ added in v0.6.2
func (lh *LoggedHandler) AddVhost(vhost *Vhost)
func (*LoggedHandler) CreateTLSConfig ¶ added in v0.6.2
func (lh *LoggedHandler) CreateTLSConfig() *tls.Config
Create multi-certificate TLS config from vhost config
func (*LoggedHandler) DumpServers ¶ added in v0.6.2
func (lh *LoggedHandler) DumpServers(w io.Writer)
DumpServers to the given writer
func (*LoggedHandler) GetVhost ¶ added in v0.10.1
func (lh *LoggedHandler) GetVhost(host string) *Vhost
func (*LoggedHandler) RemoveVhost ¶ added in v0.6.3
func (lh *LoggedHandler) RemoveVhost(host string)
func (*LoggedHandler) ServeHTTP ¶ added in v0.6.2
func (lh *LoggedHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
type Vhost ¶
type Vhost struct { Host string // virtual host name ServiceHost string // service host or IP Port int // service port Handler http.Handler Cert string // TLS Certificate Key string // TLS Private Key // contains filtered or unexported fields }
Vhost represents a single backend service
func CreateVhost ¶
CreateVhost for the host:port pair, optionally with a TLS cert
func (*Vhost) BufferAsString ¶ added in v0.10.1
func (*Vhost) NewLogListener ¶ added in v0.10.1
func (v *Vhost) NewLogListener() LogListener
func (*Vhost) RemoveLogListener ¶ added in v0.10.1
func (v *Vhost) RemoveLogListener(logChan LogListener)
type VhostMux ¶
VhostMux is an http.Handler whose ServeHTTP forwards the request to backend Servers according to the incoming request URL
func CreateVhostMux ¶
CreateVhostMux config, optionally initialized with a list of bindings
func (*VhostMux) DumpServers ¶ added in v0.10.1
DumpServers to the given writer