realip

package
v1.23.2 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2026 License: MIT Imports: 5 Imported by: 3 modules, 3 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package realip extracts a real IP address from the request.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Get

func Get(r *http.Request) (string, error)

Get returns real IP from the given request. It checks headers in the following priority order:

  1. X-Real-IP - trusted proxy (nginx/reproxy) sets this to actual client
  2. CF-Connecting-IP - Cloudflare's header for original client
  3. X-Forwarded-For - leftmost public IP (original client in CDN chain)
  4. RemoteAddr - fallback for direct connections

Only public IPs are accepted from headers; private/loopback/link-local IPs are skipped.

Types

This section is empty.

Jump to

Keyboard shortcuts

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