DEV Community

Noriko Yamamoto
Noriko Yamamoto

Posted on

How to write the original IP in the Apache log even via Cloudflare and Google Cloud Load Balancing (GCP LB)

Follow the Cloudflare Document below.

Restoring original visitor IPs: Logging visitor IP addresses with mod_cloudflare

And then, Add and for CloudFlareRemoteIPTrustedProxy.

<IfModule cloudflare_module>
    CloudFlareRemoteIPHeader X-Forwarded-For
    CloudFlareRemoteIPTrustedProxy [your load balancer’s IP]
Enter fullscreen mode Exit fullscreen mode

After restart httpd, You will see the original visitor IPs on your apache access logs.

FYI: GCP Document of External HTTP(S) Load Balancing Source IP addresses

Discussion (0)