-
-
Notifications
You must be signed in to change notification settings - Fork 213
Issue with IP address #5830
Comments
I use the first IP in my modules |
I've notice the fiest IP was also mine in the list. However multiple sources say you should use the last one... |
From what you've told, the last one should be the one of the last proxy before the requesting proxy. [PC] -> [Proxy 1] -> [Proxy 2] -> [Contao] So first of HTTP_X_FORWARDED_FOR would be IP of PC and second (last) would be IP of Proxy 1. REMOTE_ADDR is Proxy 2. (Thats just my logic out of what you told, to be confirmed) Edit: A @BugBuster1701 's wiki link confirms it. @aschempp |
That is correct. However, the sources say that you can only trust the last IP (the one your proxy server added), all other could be faked... |
The actual question is why you want |
Method description:
Do I need to say something else? ^^ |
The comment just says that the function will try to return the real remote address ( |
|
Fixed in 414a81e then. |
thanks! |
I just came against this again. The issue with the first IP is, that clients can fake this in their browsers. This makes the IP address unusable for any verifications. I think we should discuss again if to use the first or last IP... |
You can not trust any HTTP_X_* header. |
Exactly what I said. |
We have come up with a solution in the @contao/workgroup-core call:
|
if ($_SERVER['HTTP_X_FORWARDED_FOR'] != '') {
$_SERVER['HTTP_X_FORWARDED_FOR'] = array_map('trim', explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']));
$_SERVER['HTTP_X_FORWARDED_FOR'] = array_diff($_SERVER['HTTP_X_FORWARDED_FOR'], array('1.2.3.4', '2.3.4.5', '.3.4.5.6', '4.5.6.7'));
$_SERVER['HTTP_X_FORWARDED_FOR'] = array_pop($_SERVER['HTTP_X_FORWARDED_FOR']);
} |
As a hint: https://github.com/symfony/HttpFoundation/blob/master/Request.php#L752 |
This is good, but the docblock of the getClientIps is wrong. In their Impl the most trusted one is the left most because of the array_reverse at the end (this is done for easy access in the getClientIp method) |
Implemented in c84bc16. |
Today I had an issue with
Environment::ip()
, it returned a comma separated list of IP addresses.Apparently,
HTTP_X_FORWARDED_FOR
can be a comma separated list, butEnvironment::ip()
should always return only one IP...https://www.google.ch/search?client=safari&rls=en&q=http_x_forwarded_for+multiple+addresses&ie=UTF-8&oe=UTF-8&redir_esc=&ei=xC2fUb3BGYeXPe7wgSA
The text was updated successfully, but these errors were encountered: