Categorygithub.com/codeskyblue/realip
modulepackage
0.1.0
Repository: https://github.com/codeskyblue/realip.git
Documentation: pkg.go.dev

# README

RealIP

Get real IP behide nginx (Do not ignore private address)

Follows the rule of X-Forwardd-For and X-Real-IP

Refs: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-For

Install

go get -v github.com/codeskyblue/realip

Usage

package main

import "github.com/codeskyblue/realip"

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

Thanks to

LICENSE

MIT

# Functions

FromRequest return real request IP.