All IP addresses show up as 127.0.0.1

Get help with installation and running phpBB 3.0.x here. Please do not post bug reports, feature requests, or MOD-related questions here.
Scam Warning
Forum rules
END OF SUPPORT: 1 January 2017 (announcement)
Locked
haliphax
Registered User
Posts: 5
Joined: Tue Jan 12, 2010 1:55 pm

All IP addresses show up as 127.0.0.1

Post by haliphax »

I noticed recently that my new forum (which is working great otherwise, by the way.. kudos!) isn't actually tracking anyone's IP address. Everyone's IP address shows up as 127.0.0.1 in all of the admin screens.

Am I possibly missing some utility on my system, or have it misconfigured?

I'm running phpBB 3.0.6, OS: Debian Lenny on a VPS with lighttpd as the HTTP server.

I haven't been able to find anything via Google, this forum's search feature, or the phpBB bugtracker. Any assistance would be greatly appreciated.

Thanks!
Last edited by ric323 on Tue Jan 12, 2010 10:06 pm, edited 1 time in total.
Reason: Topic icon changed
User avatar
AdamR
Former Team Member
Posts: 9731
Joined: Tue Mar 02, 2004 5:40 pm
Location: Tampa, Florida
Name: Adam Reyher
Contact:

Re: All IP addresses show up as 127.0.0.1

Post by AdamR »

Are the server's access logs recording the IP addresses correctly?

- Adam
phpBB Support: Welcome | Userguide | Knowledge Base | Search
Honored supporter of the phpBB Group!
"If I have seen a little further it is by standing on the shoulders of Giants." - Isaac Newton
haliphax
Registered User
Posts: 5
Joined: Tue Jan 12, 2010 1:55 pm

Re: All IP addresses show up as 127.0.0.1

Post by haliphax »

If you're talking about the logs viewable from the ACP, then no, it's displaying them all as 127.0.0.1 (that's what brought this issue to my attention in the first place). If you're talking about some text file that phpBB3 produces when being used, then I don't know where to look for that. If you're talking about the access logs from my HTTP server, then yes, they are being logged correctly there.

It seems that sometimes the IP address is logged in the lighttpd access log as IPv6 (::ffff:address) and sometimes it's logged as IPv4 (address with no prefix)... but all IPs I can find anywhere from anyone are registered in phpBB3 are 127.0.0.1.
User avatar
AdamR
Former Team Member
Posts: 9731
Joined: Tue Mar 02, 2004 5:40 pm
Location: Tampa, Florida
Name: Adam Reyher
Contact:

Re: All IP addresses show up as 127.0.0.1

Post by AdamR »

In the Admin Panel, go to System > PHP Information.

What value is being displayed for "REMOTE_ADDR?"

EDIT: Also, what are the values for "SERVER_NAME" and "HTTP_HOST" ?

- Adam
phpBB Support: Welcome | Userguide | Knowledge Base | Search
Honored supporter of the phpBB Group!
"If I have seen a little further it is by standing on the shoulders of Giants." - Isaac Newton
haliphax
Registered User
Posts: 5
Joined: Tue Jan 12, 2010 1:55 pm

Re: All IP addresses show up as 127.0.0.1

Post by haliphax »

REMOTE_ADDR: My valid IP address, prefixed with :ffffff:
SERVER_NAME: My valid subdomain, domain, and suffix (i.e., forum.mysite.com)
HTTP_HOST: The same as SERVER_NAME.
User avatar
AdamR
Former Team Member
Posts: 9731
Joined: Tue Mar 02, 2004 5:40 pm
Location: Tampa, Florida
Name: Adam Reyher
Contact:

Re: All IP addresses show up as 127.0.0.1

Post by AdamR »

There's a couple of possibilities. This can sometimes happen if mod_proxy is loaded into lighttpd and not configured correctly (more info).

The other possibility that I have seen is if there are multiple instances of the web server running, for example, one for PHP5 and the other for PHP4, which causes one request to be forwarded to the other, resulting in the IP address being passed as 127.0.0.1.

Edit: Actaully, this may be related to a lighttpd and/or Debian implementation. A quick google search turned up this: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=481317

phpBB simply uses REMOTE_ADDR. If it's being passed with the prefix (improperly), it's defaulting to a loopback address.

includes/session.php

Code: Select all

		// Why no forwarded_for et al? Well, too easily spoofed. With the results of my recent requests
		// it's pretty clear that in the majority of cases you'll at least be left with a proxy/cache ip.
		$this->ip = (!empty($_SERVER['REMOTE_ADDR'])) ? htmlspecialchars((string) $_SERVER['REMOTE_ADDR']) : '';
		$this->ip = preg_replace('#[ ]{2,}#', ' ', str_replace(array(',', ' '), ' ', $this->ip));

		// split the list of IPs
		$ips = explode(' ', $this->ip);

		// Default IP if REMOTE_ADDR is invalid
		$this->ip = '127.0.0.1';
- Adam
phpBB Support: Welcome | Userguide | Knowledge Base | Search
Honored supporter of the phpBB Group!
"If I have seen a little further it is by standing on the shoulders of Giants." - Isaac Newton
haliphax
Registered User
Posts: 5
Joined: Tue Jan 12, 2010 1:55 pm

Re: All IP addresses show up as 127.0.0.1

Post by haliphax »

I don't suppose you could just tell me where in the code it does this, so that I could mod it to strip the :ffffff: out? I'd rather not try to fix the problem with lighttpd, since it's most likely going to be resolved with a patch in the incredibly near future.
haliphax
Registered User
Posts: 5
Joined: Tue Jan 12, 2010 1:55 pm

Re: All IP addresses show up as 127.0.0.1

Post by haliphax »

I got it to work. Thank you so much! For future reference, here's the code I had to add (starting on or around line 276 of session.php):

Code: Select all

foreach ($ips as $ip)
{
	// ****** here's the line that I added ******
	$ip = preg_replace('/::[0-9a-f]+:(?=(\d{1,3}\.){3}\d{1,3})/i', '', $ip);
	
	// check IPv4 first, the IPv6 is hopefully only going to be used very seldomly
	if (!empty($ip) && !preg_match(get_preg_expression('ipv4'), $ip) && !preg_match(get_preg_expression('ipv6'), $ip))
	{
		// Just break
		break;
	}

	// Use the last in chain
	$this->ip = $ip;
}
MakX
Registered User
Posts: 3
Joined: Mon Jan 18, 2010 9:35 pm

Re: All IP addresses show up as 127.0.0.1

Post by MakX »

I wanted to register to post especially on this topic. This just started happening to me today, and your fix worked perfectly! Thank you!

It is noteworthy I'm also running Debian with Lighttpd on a VPS.
User avatar
bantu
3.0 Release Manager
3.0 Release Manager
Posts: 2523
Joined: Mon Jul 10, 2006 9:58 pm
Name: Andreas Fischer

Re: All IP addresses show up as 127.0.0.1

Post by bantu »

This issue has been reported to the bug tracker: http://tracker.phpbb.com/browse/PHPBB3-9091
Powered by Coffee
elpanatibu
Registered User
Posts: 38
Joined: Sun Nov 16, 2008 6:34 pm

Re: All IP addresses show up as 127.0.0.1

Post by elpanatibu »

hello, I recently move my phpbb3 forum from free host to premium host. everything works fine. but now
All IP addresses users, my, show up as 127.0.0.1. so isn't actually tracking anyone's IP address. before migration that working fine. please any Suggestion? add that line dont work for me.. :(
User avatar
victory1
Registered User
Posts: 935
Joined: Sun Oct 10, 2010 6:47 pm
Contact:

Re: All IP addresses show up as 127.0.0.1

Post by victory1 »

Thank you for this! I had the same problem, except it was not 127.0.0.1, everyone was said to be using my IP. Adding you fix solved the problem!
User avatar
victory1
Registered User
Posts: 935
Joined: Sun Oct 10, 2010 6:47 pm
Contact:

Re: All IP addresses show up as 127.0.0.1

Post by victory1 »

elpanatibu wrote:hello, I recently move my phpbb3 forum from free host to premium host. everything works fine. but now
All IP addresses users, my, show up as 127.0.0.1. so isn't actually tracking anyone's IP address. before migration that working fine. please any Suggestion? add that line dont work for me.. :(
I also moved from a free host and here's what I discovered, the fix does work for all new post since our moved on October 22nd but for all previous post the IP is that of the computer that was used to run the script converter. I can live with that since I know never to banned that IP! I hope this help.
starwar
Registered User
Posts: 99
Joined: Tue Nov 21, 2006 7:22 pm

Re: All IP addresses show up as 127.0.0.1

Post by starwar »

For my forum, all user ip show my host ip.
How can I change it?
version-phpbb 3.0.8


thk
Locked

Return to “[3.0.x] Support Forum”