Hi DO Community,
I have 2 droplet,
serverA - varnish serverB - LAMP (wordpress)
My LAMP show serverA private IP instead of real client IP. How I can get real client IP in this situation?
Thank you.
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
In order to have Varnish pass on the real client IP to your Apache access log, you’ll need to edit your Varnish configuration (
/etc/varnish/default.vcl
on Ubuntu) to add anX-Forwarded-For
header. Find thevcl_recv
section and added the following:(Note: If you are using Varnish < 4.0 change
unset
toremove
as the syntax is different.)Than, in your Apache Virtual Host, set a CustomLog format:
Finally, restart both Apache and Varnish for the changes to take effect: