Posted by Noe_ on June 5, 2013 at 11:26am
Hi there,
I am going crazy about the fact that Drupal 7 does not register the public ip's from my users after installing Varnish.
I have these variables n my settings.php:
$conf['reverse_proxy'] = TRUE;
$conf['cache'] = 1;
$conf['cache_lifetime'] = 0;
$conf['page_cache_maximum_age'] = 21600;
$conf['reverse_proxy_header'] = 'HTTP_X_FORWARDED_FOR';
$conf['reverse_proxy_addresses'] = array('127.0.0.1');
$conf['omit_vary_cookie'] = TRUE;
Everywhere I look people say that this is enough, however with my site it still registers everyone is coming from 127.0.0.1
While I was fine with that, now I get a lot of hits from spammers, and I need to block some ip addresses but that is not possible if Drupal does not register the ip addresses.
TIA

Comments
Did you set it on Varnish?
You seems to have set up everything on Drupal to use the X-Forwarded-For header, but did you set it up on Varnish?
You need to also tell varnish to add that header when making the request to the web server.
sub vcl_recv {if (req.restarts == 0) {
if (req.http.x-forwarded-for) {
set req.http.X-Forwarded-For =
req.http.X-Forwarded-For + “, ” + client.ip;
} else {
set req.http.X-Forwarded-For = client.ip;
}
}
}
You need to add this to the varnish vcl_recv, this would add the X-Forwarded-For header and then Drupal can use that header to retrieve the user's IP.
~Nestor
Nestor Mata
http://nestor.profesional.co.cr/es
I knew it had to be something
I knew it had to be something stupid like that.
Thanks a lot, you know how long I have searched for a solutions.
Noe
Almost there...!
Hi!
Nestar has already commented something that you should do and it will surely solve your problem in any case. However, you can also read out some handy manuals like http://drupal.org/project/user_restrictions and configuration statistics. Here is something i found on stack overflow : http://stackoverflow.com/questions/3776363/drupal-how-can-i-read-ip-addr...
Cloud Professional
Is it good trick
is it good trick, if we write
$_SERVER["REMOTE_ADDR"] = $_SERVER['HTTP_X_FORWARDED_FOR'];
at the end of settings.php, It works for me.