Incorrect IP Addresses

Get help with installation and running phpBB 3.0.x here. Please do not post bug reports, feature requests, or MOD-related questions here.
Get Involved
Forum rules
END OF SUPPORT: 1 January 2017 (announcement)
Locked
Haravikk
Registered User
Posts: 261
Joined: Sat Nov 02, 2002 4:42 pm

Incorrect IP Addresses

Post by Haravikk » Fri Dec 04, 2015 8:47 am

Support Request Template
What version of phpBB are you using? phpBB 3.0.14
What is your board's URL? http://www.legendofkrystal.com/forum
Who do you host your board with? DreamHost
How did you install your board? I used the download package from phpBB.com
What is the most recent action performed on your board? Update from a previous version of phpBB3
Is registration required to reproduce this issue? Yes
Do you have any MODs installed? Yes
Do you have any extensions installed? No
What version of phpBB3 did you update from? phpBB 3.0.12
What MODs do you have installed? Various (custom)
What styles do you currently have installed? No answer given
What language(s) is your board currently using? en-GB
Which database type/version are you using? MariaDB
What is your level of experience? Experienced with PHP and phpBB
What username can be used to view this issue? No answer given
What password can be used to view this issue? No answer given
What actions did you take (updating your board; installing a MOD, style or extension; etc.) prior to this problem becoming noticeable? Moved to a new server.
Please describe your problem. Basically I'm no longer seeing the correct IP addresses for users after moving to a new server; my domain is proxied through CloudFlare, and instead I'm seeing the IP addresses of the CloudFlare servers that each user is connecting via.

This happened since moving to a new server, but otherwise nothing has changed (I only mentioned the phpBB upgrade because it was recent). I've enabled verification of X_FORWARDED_FOR, as well as the option to tie login attempts to that field, but phpBB just doesn't seem to want to use the IP addresses found in that header, even though they are set correctly (and contain the user's actual IP address).
Generated by SRT Generator

User avatar
KevC
Support Team Member
Support Team Member
Posts: 69419
Joined: Fri Jun 04, 2004 10:44 am
Location: Oxford, UK
Contact:

Re: Incorrect IP Addresses

Post by KevC » Fri Dec 04, 2015 8:55 am

This is something you need to talk to your hosts about. phpBB is just reporting what it's being given.
We see a lot of problems with cloudflare by the way.
-:|:- Support Request Template -:|:-
Image
Cheap UK Hosting
"In the land of the blind the little green bloke with no pupils is king - init!"

User avatar
david63
Registered User
Posts: 16665
Joined: Thu Dec 19, 2002 8:08 am
Location: Lancashire, UK
Name: David Wood
Contact:

Re: Incorrect IP Addresses

Post by david63 » Fri Dec 04, 2015 9:19 am

As Kev says there are many problems with Cloudflare and phpBB.

I seem to recall that someone else had this same problem and it was something to do with the Cloudflare settings - a search of this board, or Google, may help.
David
Remember: You only know what you know and - you don't know what you don't know!
My CDB Contributions | How to install an extension
I will not be accepting translations for any of my extensions in Github - please post any translations in the appropriate topic.
No support requests via PM or email as they will be ignored

Haravikk
Registered User
Posts: 261
Joined: Sat Nov 02, 2002 4:42 pm

Re: Incorrect IP Addresses

Post by Haravikk » Fri Dec 04, 2015 9:54 am

david63 wrote:As Kev says there are many problems with Cloudflare and phpBB.
I've never had problems before except those that I cause myself ;)
In fact on the previous host CloudFlare did nothing at all to phpBB until I made some custom modifications to force it to cache certain content (attachments, avatars and guest pages). I'm actually working on an extension version of the customisation for phpBB 3.1 so others can benefit; I was going to release the mod for phpBB 3.0 but lost track of all my changes, which is why I love that extensions are nice and modular!


Anyway, like I say the X-Forwarded-For header is set correctly by CloudFlare, my problem is that phpBB isn't using it even though I've set both "Validate X_FORWARDED_FOR header" and "Limit login attempts by X_FORWARDED_FOR header".

I think my previous server had some kind of automated CloudFlare support, so maybe it was swapping X-Forward-For into the REMOTE_HOST field, any idea how to do that, is it a PHP or nginx option?

It seems like it could solve a lot of headaches if phpBB would support using X-Forwarded-For, with appropriate warnings about trusting the source of it, of course.

Haravikk
Registered User
Posts: 261
Joined: Sat Nov 02, 2002 4:42 pm

Re: Incorrect IP Addresses

Post by Haravikk » Fri Dec 04, 2015 10:59 am

So I haven't found out what my old server did yet, but here's the solution I'm using to add X-Forwarded-For IP support to phpBB:

Find This Line in includes/session.php:

Code: Select all

		$ips = explode(' ', trim($this->ip));
After Add:

Code: Select all

		if (!empty($_SERVER['HTTP_X_FORWARDED_FOR']) && $config['ip_login_limit_use_forwarded'])
		{
			$ips = array_merge($ips, preg_split('/ *[, ] */', $_SERVER['HTTP_X_FORWARDED_FOR']));
		}
Basically if you've enabled IP login limits tied to the X-Forwarded-For header, and the header exists, then phpBB will add the contents to the $ips array when it decides which IP address to use for the current user. The only problem is that technically with this change added you don't need to enable X-Forwarded-For login limits, but it seemed the most sensible way to add it via config setting, as opposed to just blindly using the forwarded-for header like some fixes have suggested.

Of course there's now the standardised Forwarded-For header as well, but I've yet to see it in the wild.

User avatar
Noxwizard
Support Team Leader
Support Team Leader
Posts: 10346
Joined: Mon Jun 27, 2005 8:41 pm
Location: Texas, USA
Name: Patrick Webster
Contact:

Re: Incorrect IP Addresses

Post by Noxwizard » Fri Dec 04, 2015 8:53 pm

As Kevin mentioned, this is really something your host needs to address as other things, like your access logs, will remain incorrect. CloudFlare has put out modules for several HTTP servers and hosting backends: https://www.cloudflare.com/resources-downloads/ DreamHost just needs to add it or activate it on your account.
[Support Template] - [Read Before Posting] - [phpBB Knowledge Base]
Do not contact me for private support, please share the question in our forums.

Locked

Return to “[3.0.x] Support Forum”