oxy: github.com/vulcand/oxy/forward Index | Files

package forward

import "github.com/vulcand/oxy/forward"

Package forward implements http handler that forwards requests to remote server and serves back the response websocket proxying support based on https://github.com/yhat/wsutil

Index

Package Files

fwd.go headers.go post_config.go rewrite.go

Constants

const (
    StateConnected = iota
    StateDisconnected
)

Connection states

const (
    XForwardedProto        = "X-Forwarded-Proto"
    XForwardedFor          = "X-Forwarded-For"
    XForwardedHost         = "X-Forwarded-Host"
    XForwardedPort         = "X-Forwarded-Port"
    XForwardedServer       = "X-Forwarded-Server"
    XRealIp                = "X-Real-Ip"
    Connection             = "Connection"
    KeepAlive              = "Keep-Alive"
    ProxyAuthenticate      = "Proxy-Authenticate"
    ProxyAuthorization     = "Proxy-Authorization"
    Te                     = "Te" // canonicalized version of "TE"
    Trailers               = "Trailers"
    TransferEncoding       = "Transfer-Encoding"
    Upgrade                = "Upgrade"
    ContentLength          = "Content-Length"
    SecWebsocketKey        = "Sec-Websocket-Key"
    SecWebsocketVersion    = "Sec-Websocket-Version"
    SecWebsocketExtensions = "Sec-Websocket-Extensions"
    SecWebsocketAccept     = "Sec-Websocket-Accept"
)

Headers

Variables

var HopHeaders = []string{
    Connection,
    KeepAlive,
    ProxyAuthenticate,
    ProxyAuthorization,
    Te,
    Trailers,
    TransferEncoding,
    Upgrade,
}

HopHeaders Hop-by-hop headers. These are removed when sent to the backend. http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html Copied from reverseproxy.go, too bad

var WebsocketDialHeaders = []string{
    Upgrade,
    Connection,
    SecWebsocketKey,
    SecWebsocketVersion,
    SecWebsocketExtensions,
    SecWebsocketAccept,
}

WebsocketDialHeaders Websocket dial headers

var WebsocketUpgradeHeaders = []string{
    Upgrade,
    Connection,
    SecWebsocketAccept,
    SecWebsocketExtensions,
}

WebsocketUpgradeHeaders Websocket upgrade headers

var XHeaders = []string{
    XForwardedProto,
    XForwardedFor,
    XForwardedHost,
    XForwardedPort,
    XForwardedServer,
    XRealIp,
}

XHeaders X-* headers

func BufferPool Uses

func BufferPool(pool httputil.BufferPool) optSetter

BufferPool specifies a buffer pool for httputil.ReverseProxy.

func ErrorHandler Uses

func ErrorHandler(h utils.ErrorHandler) optSetter

ErrorHandler is a functional argument that sets error handler of the server

func IsWebsocketRequest Uses

func IsWebsocketRequest(req *http.Request) bool

IsWebsocketRequest determines if the specified HTTP request is a websocket handshake request

func Logger Uses

func Logger(l log.FieldLogger) optSetter

Logger defines the logger the forwarder will use.

It defaults to logrus.StandardLogger(), the global logger used by logrus.

func PassHostHeader Uses

func PassHostHeader(b bool) optSetter

PassHostHeader specifies if a client's Host header field should be delegated

func ResponseModifier Uses

func ResponseModifier(responseModifier func(*http.Response) error) optSetter

ResponseModifier defines a response modifier for the HTTP forwarder

func Rewriter Uses

func Rewriter(r ReqRewriter) optSetter

Rewriter defines a request rewriter for the HTTP forwarder

func RoundTripper Uses

func RoundTripper(r http.RoundTripper) optSetter

RoundTripper sets a new http.RoundTripper Forwarder will use http.DefaultTransport as a default round tripper

func StateListener Uses

func StateListener(stateListener UrlForwardingStateListener) optSetter

StateListener defines a state listener for the HTTP forwarder

func Stream Uses

func Stream(stream bool) optSetter

Stream specifies if HTTP responses should be streamed.

func StreamingFlushInterval Uses

func StreamingFlushInterval(flushInterval time.Duration) optSetter

StreamingFlushInterval defines a streaming flush interval for the HTTP forwarder

func WebsocketConnectionClosedHook Uses

func WebsocketConnectionClosedHook(hook func(req *http.Request, conn net.Conn)) optSetter

WebsocketConnectionClosedHook defines a hook called when websocket connection is closed

func WebsocketTLSClientConfig Uses

func WebsocketTLSClientConfig(tcc *tls.Config) optSetter

WebsocketTLSClientConfig define the websocker client TLS configuration

type ErrorHandlingRoundTripper Uses

type ErrorHandlingRoundTripper struct {
    http.RoundTripper
    // contains filtered or unexported fields
}

ErrorHandlingRoundTripper a error handling round tripper

func (ErrorHandlingRoundTripper) RoundTrip Uses

func (rt ErrorHandlingRoundTripper) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip executes the round trip

type Forwarder Uses

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

Forwarder wraps two traffic forwarding implementations: HTTP and websockets. It decides based on the specified request which implementation to use

func New Uses

func New(setters ...optSetter) (*Forwarder, error)

New creates an instance of Forwarder based on the provided list of configuration options

func (*Forwarder) ServeHTTP Uses

func (f *Forwarder) ServeHTTP(w http.ResponseWriter, req *http.Request)

ServeHTTP decides which forwarder to use based on the specified request and delegates to the proper implementation

type HeaderRewriter Uses

type HeaderRewriter struct {
    TrustForwardHeader bool
    Hostname           string
}

HeaderRewriter is responsible for removing hop-by-hop headers and setting forwarding headers

func (*HeaderRewriter) Rewrite Uses

func (rw *HeaderRewriter) Rewrite(req *http.Request)

Rewrite rewrite request headers

type OxyLogger Uses

type OxyLogger interface {
    log.FieldLogger
    GetLevel() log.Level
}

OxyLogger interface of the internal

type ReqRewriter Uses

type ReqRewriter interface {
    Rewrite(r *http.Request)
}

ReqRewriter can alter request headers and body

type UrlForwardingStateListener Uses

type UrlForwardingStateListener func(*url.URL, int)

UrlForwardingStateListener URL forwarding state listener

Package forward imports 17 packages (graph) and is imported by 116 packages. Updated 2019-05-21. Refresh now. Tools for package owners.