Table of Contents

About

The users / original IP address of a request is stored in the following headers

With this IP, you can perform geolocalization of your users

X-Forwarded-For

An HTTP reverse proxy uses non-standard headers to inform the upstream server about the user’s IP address and other request properties:

X-Forwarded-For: ipClient, ipProxy1, ipProxy2
X-Real-IP: 12.34.56.78
X-Forwarded-Host: example.com
X-Forwarded-Proto: https

where:

Client Restoration

On web server, you can restore the IP in the http log to the client IP (and not to the proxy) via:

  • a module of the server 1)
  • or by modifying the log format

For instance, with nginx:

log_format  proxy  '$http_x_forwarded_for - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" ""';
access_log  /var/log/nginx/access.log proxy;

Documentation