Hi there, We currently are running our site through 2 loadbalancing squid proxies. This is resulting in amember seeing everyones IP as the proxy IPs. This is causing problems like such: Code: MYSQL ERROR: Duplicate entry '::ffff:xxx.xxx.xxx-2' for key 2 in query: INSERT INTO amember_failed_login (ip, login_type, failed_logins, last_failed) VALUES ('::ffff:xx.xxx.xxx.xxx', '2', 1, 1271645241) Now, we have turned on Forwarded-For in the squid config file, and we have enabled it in the lighttpd config also. All we require now is for aMember to read the X_FORWARDED_FOR instead of the REMOTE_ADDR header. How would we go about doing this? Any help is very much appreciated
If requests are coming ONLY via proxy, edit file amember/config.inc.php add line right after opening <?php $_SERVER['REMOTE_ADDR'] = @$_SERVER['X_FORWARDED_FOR'];
Which in turn now produces these errors and logs no IP address: Code: WARNING: gethostbyaddr() [function.gethostbyaddr]: Address is not a valid IPv4 or IPv6 address in line 1605 of file mysql.inc.php WARNING: Cannot modify header information - headers already sent by (output started at /var/www/amember/rconfig.inc.php:401) in line 371 of file check.inc.php WARNING: Cannot modify header information - headers already sent by (output started at /var/www/amember/rconfig.inc.php:401) in line 372 of file check.inc.php
Remove this from mysql.inc.php: Code: if (preg_match('/proxy\.aol\.com$/', gethostbyaddr($REMOTE_ADDR))) return; should help.
Yeah that helps, but in the aMember CP it is not logging any IP address with that code at the top of config.inc.php. We're getting there
fixed. Right to let everyone else know the header coming from squid proxy is not 'X_FORWARDED_FOR' but it is 'HTTP_X_FORWARDED_FOR' which the above post helped me to find out so thank you. I hope this can help others with the same issues as me Thanks again