On my server I have installed Varnish in front of nginx, to serve static files faster. When using my site I have found following bug: Every comment on my wordpress blog is coming from localhost (127.0.0.1) and nobody is now allowed to write comments (wordpress is blocking too much comments from one ip). How can I make comments to be posted to nginx (wordpress) with their original ip, or how can I disable comments lockdown?
Commenter is right, nginx is just as fast as varnish at serving up static files. There's often not a reason to have the 2 in tandem, except in certain circumstances (when using advanced full page caching, ESI, etc).
To answer your question directly, you'll need to do some tinkering within Wordpress itself to get it to discover the real IP. It's a bit of a hack, but since Wordpress is full of them, it should be fine (and I've done this many times before in production with success).
wp-config.php file, somewhere (near the top is good) put;
$_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_X_FORWARDED_FOR'];
This is under the assumption that your Varnish server is sending the
X-Forwarded-For header. Instructions how to do this if it doesn't already can be found here.
This fools Wordpress into believing that whatever the IP is sent by the proxy is the real user's IP. In most cases this is safe, some people would worry that headers are too easy to spoof, however if you have a reverse proxy that explicity defines that header (read: overwrites anything that might be incoming with the correct value), it will be fine.
Hope this helps.