Nginx Access Logs Show 127.0.0.1 or Cloudflare IP Instead of Visitor

Missing `set_real_ip_from` and `real_ip_header` behind CDN or reverse proxy.

Runs locally in browser Free · No login Independently Verified 2026-11-25 v4.1.0
Identifier: Nginx Access Logs Show 127.0.0.1 or Cloudflare IP Instead of Visitor Platform: Nginx
Common Root Causes:
  • Missing `set_real_ip_from` and `real_ip_header` behind CDN or reverse proxy.

Interactive Diagnostic Checklist

Verified Solutions:
  1. Configure `set_real_ip_from` strictly for trusted proxy CIDRs and `real_ip_header CF-Connecting-IP` / `X-Forwarded-For`.
Safe Diagnostic Command:
tail -n 10 /var/log/nginx/access.log
Warning: Verify configuration changes in staging or with dry-run flags (e.g. nginx -t) before reloading production services.

Technical Explanation

Missing `set_real_ip_from` and `real_ip_header` behind CDN or reverse proxy. Recommended diagnostic: `tail -n 10 /var/log/nginx/access.log`. Remediation: Configure `set_real_ip_from` strictly for trusted proxy CIDRs and `real_ip_header CF-Connecting-IP` / `X-Forwarded-For`.

Worked Examples

  • Run `tail -n 10 /var/log/nginx/access.log` to verify root cause before applying the remediation.

Limitations & Assumptions

  • Always verify configuration changes in staging or with dry-run flags (e.g. `nginx -t`) before reloading production services.

Source References & Verification

Resource ID: err-nginx-real-ip-shows-proxy · Independently verified: 2026-11-25

Related Resources