Documentation
¶
Overview ¶
Package clientip decides which address a request really came from.
Rivolt sits behind Cloudflare and an in-cluster load balancer, so the connection's peer address is the balancer (a 10.42.x.x pod address), the same for every visitor. The visitor's address arrives in CF-Connecting-IP, which is only believable when the connection came from a proxy we trust: a private-range address (our own balancer; it masquerades, so Cloudflare's edge is never the direct peer) or a Cloudflare edge address. From anyone else every forwarding header is ignored, so a client cannot choose its own rate-limit bucket, logged address or session address by sending CF-Connecting-IP, X-Forwarded-For, X-Real-IP or True-Client-IP.
Middleware replaces chi's RealIP, which trusted those headers from anyone.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Middleware ¶
Middleware sets r.RemoteAddr to the real client address ("ip:port" form, port taken from the connection) and keeps the connection's own peer address in the context (see Peer).
func Peer ¶
Peer is the address of the connection itself (the proxy that connected), whatever Middleware rewrote RemoteAddr to. Trust decisions about the proxy (for example the trusted-proxy SSO headers) must use this, not RemoteAddr.
Types ¶
This section is empty.