HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Modulewai-extra-3.1.16Haskell2010

Network.Wai.Middleware.RealIp

Infer the remote IP address using headers

  • 5 values
valuerealIpTrusted :: HeaderName -> (IP -> Bool) -> Middleware
#

Infer the remote IP address using the given header, but only if the request came from an IP that is trusted by the provided predicate.

The last non-trusted address is used to replace the remoteHost in the Request, unless all present IP addresses are trusted, in which case the first address is used. Invalid IP addresses are ignored, and the remoteHost value remains unaltered if no valid IP addresses are found.

Examples:

 realIpTrusted "X-Forwarded-For" $ flip ipInRange "10.0.0.0/8"
 realIpTrusted "X-Real-Ip" $ \ip -> any (ipInRange ip) defaultTrusted
valueipInRange :: IP -> IPRange -> Bool
#

Check if the given IP address is in the given range.

IPv4 addresses can be checked against IPv6 ranges, but testing an IPv6 address against an IPv4 range is always False.