proxy

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: May 7, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	XRealIP       = http.CanonicalHeaderKey("X-Real-IP")
	XProxy        = http.CanonicalHeaderKey("X-Proxy")
	XForwardedFor = http.CanonicalHeaderKey("X-Forwarded-For")
	XServer       = http.CanonicalHeaderKey("X-Server")
)
View Source
var ConnectionTimeout = 3 * time.Second
View Source
var (
	ReverseProxy = "Balancer-Reverse-Proxy"
)

Functions

func GetIP

func GetIP(r *http.Request) string

func GetNode

func GetNode(url *url.URL) string

func IsBackendAlive

func IsBackendAlive(host string) bool

Types

type HTTPProxy

type HTTPProxy struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

HTTPProxy 是一个 HTTP 代理

func NewHTTPProxy

func NewHTTPProxy(targetNodes []string, algorithm string) (*HTTPProxy, error)

NewHTTPProxy 新建一个 HTTP 代理

func (*HTTPProxy) HealthCheck

func (h *HTTPProxy) HealthCheck(interval uint)

HealthCheck 为每个代理启用健康检查 goroutine

func (*HTTPProxy) ReadAlive

func (h *HTTPProxy) ReadAlive(url string) bool

ReadAlive 读取站点的活动状态

func (*HTTPProxy) ServeHTTP

func (h *HTTPProxy) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServerHTTP 实现 http.Handler 接口

func (*HTTPProxy) SetAlive

func (h *HTTPProxy) SetAlive(url string, alive bool)

SetAlive 设置站点的活动状态

Jump to

Keyboard shortcuts

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