realip

package
v1.21.0 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2026 License: MIT Imports: 5 Imported by: 1

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