simpleproxy

package module
v0.0.0-...-05d31fb Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2020 License: MIT Imports: 15 Imported by: 2

README

simpleproxy

simple proxy is a really simple reverse proxy - mostly for development purposes.

installation

go get github.com/ybrs/simpleproxy.git

or

git clone
go build

usage

simpleproxy -listen 0.0.0.0:9001 -target http://localhost:8000

also simpleproxy can handle static files too

simpleproxy -listen 0.0.0.0:9001 -target http://localhost:8000 -static /media/:./media/

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BadGatewayMessage = `<html>
<body>
<h1>502 Bad Gateway</h1>
<p>Can't connect to upstream server, please try again later.</p>
</body>
</html>`

Functions

func CARootPath

func CARootPath() string

func CertPath

func CertPath() string

func CreateProxy

func CreateProxy(targetURL url.URL, vhost string) *httputil.ReverseProxy

func MakeCert

func MakeCert(host string) (string, string, error)

MakeCert for the give hostname, if it doesn't already exist.

Types

type LogRecord

type LogRecord struct {
	http.ResponseWriter
	// contains filtered or unexported fields
}

func (*LogRecord) Write

func (r *LogRecord) Write(p []byte) (int, error)

func (*LogRecord) WriteHeader

func (r *LogRecord) WriteHeader(status int)

type LoggedMux

type LoggedMux struct {
	*http.ServeMux
	VhostLogListeners map[string]chan string
}

func NewLoggedMux

func NewLoggedMux() *LoggedMux

func (*LoggedMux) AddLogListener

func (mux *LoggedMux) AddLogListener(host string, listener chan string)

func (*LoggedMux) RemoveLogListener

func (mux *LoggedMux) RemoveLogListener(host string)

func (*LoggedMux) ServeHTTP

func (mux *LoggedMux) ServeHTTP(w http.ResponseWriter, r *http.Request)

type ProxyTransport

type ProxyTransport struct {
}

func (*ProxyTransport) RoundTrip

func (t *ProxyTransport) RoundTrip(request *http.Request) (*http.Response, error)

type Vhost

type Vhost struct {
	Host    string
	Port    int
	Handler http.Handler
	Cert    string
	Key     string
}

func CreateVhost

func CreateVhost(input string, useTLS bool) (*Vhost, error)

CreateVhost for the host:port pair, optionally with a TLS cert

type VhostMux

type VhostMux struct {
	Servers map[string]*Vhost
}

VhostMux is an http.Handler whose ServeHTTP forwards the request to backend Servers according to the incoming request URL

func CreateVhostMux

func CreateVhostMux(bindings []string, useTLS bool) *VhostMux

CreateVhostMux config from list of bindings

func (*VhostMux) ServeHTTP

func (v *VhostMux) ServeHTTP(w http.ResponseWriter, r *http.Request)

Directories

Path Synopsis
bin

Jump to

Keyboard shortcuts

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