realip

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 17, 2018 License: MIT Imports: 3 Imported by: 6

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromRequest

func FromRequest(r *http.Request) string

FromRequest return real request IP

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL