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 ¶
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.
Click to show internal directories.
Click to hide internal directories.