by tomasen

tomasen /realip

a golang library that can get client's real public ip address from http request headers

137 Stars 34 Forks Last release: Not found MIT License 23 Commits 0 Releases

Available items

No Items, yet!

The developer of this repository has not created any items for sale yet. Need a bug fixed? Help with integration? A different license? Create a request here:



Go package that can be used to get client's real public IP, which usually useful for logging HTTP server.


  • Follows the rule of X-Real-IP
  • Follows the rule of X-Forwarded-For
  • Exclude local or private address


package main

import ""

func (h *Handler) ServeIndexPage(w http.ResponseWriter, r *http.Request, ps httprouter.Params) { clientIP := realip.FromRequest(r) log.Println("GET / from", clientIP) }


Commited code must pass:

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.