tproxy

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HeaderXProxyClientIP = "X-Proxy-ClientIP"
	HeaderXProxyToken    = "X-Proxy-Token" // #nosec G101
	HeaderXProxyTime     = "X-Proxy-Time"
	HeaderXProxyPass     = "X-Proxy-Pass"
)

Variables

This section is empty.

Functions

func GetClientIP

func GetClientIP(c *fiber.Ctx) string

GetClientIP 获取客户端 IP 1. 上下文存储中获取 2. 下游代理头信息中获取 3. TCP 协议 RemoteIP() immutable

func ProxyHandler

func ProxyHandler(backendServers []string, timeout time.Duration, backendHost string) fiber.Handler

ProxyHandler 请求代理

示例:

backendHost := "1.2.3.4:555"
backendServers := []string{"http://1.2.3.4:555"}
proxyHandler := ProxyHandler(backendServers, 1*time.Second, backendHost)
app.Use("/test/ff", proxyHandler)
6.6.6.6 请求: http://localhost:666/test/ff -> http://1.2.3.4:555/test/ff
在 1.2.3.4 服务中 GetClientIP(c) 能获取到真实客户端请求IP: 6.6.6.6

func SetClientIP

func SetClientIP(c *fiber.Ctx)

SetClientIP 首个代理加密客户端 IP, 中间代理透传 当前来访为内网 IP 会跳过设置 immutable

Types

This section is empty.

Jump to

Keyboard shortcuts

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