-
Notifications
You must be signed in to change notification settings - Fork 129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multiple layers of load balancers in 4.0 #107
Comments
Hi!
I hope they do! The changes made in symfony has been a bit confusing (and
buggy, I’ve had to file a few bug reports on it myself). It’s possibly a
bug that it’s not catching the correct client IP address in a chain of
proxies.
Question: Are the trusted proxies you have set a chain of proxies?
If that is a chain, I believe you’d only need to trust the proxy that is
directly sending requests to your app servers (rather than the full chain).
However, that may not help the issue of Request::clientIp() returning the
wrong IP address!
Can you dump out there $_SERVER array your app server receives? I’m
specifically curious about what the headers received look like so I could
recreate that and see if there’s a bug on my end, symfony’s end, or just a
change in how trustedproxy needs to be configured in that scenario.
Thanks
…On Thu, Feb 8, 2018 at 08:39 Niclas Hedam ***@***.***> wrote:
When I call Request::ips() I get an array of two IPs, where index 0 is
130.*.
[image: image]
<https://user-images.githubusercontent.com/770169/35978526-474e1db6-0ce6-11e8-9217-639efd27289d.png>
protected $proxies = [
'209.85.152.0/22',
'209.85.204.0/22',
'35.191.0.0/16',
'130.211.0.0/22',
'10.0.0.0/8',
];
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#107 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAch03iynWg1msABDCgdzzADM6ej6YaHks5tSwc9gaJpZM4R-cke>
.
|
Hi, Sorry that I haven't responded until now.
Yes. I found out that if I only trust one level of proxies, then the next level will become the client IP.
|
I'm seem to be having the same issue on an app running on AWS behind cloud front. The Request has the following headers:
The IP I'm looking for is |
Hi @MichMich ! Can you show me your laravel trustproxies middleware, and what version of laravel you're on? In your case, it sounds like it's not looking at |
It seems to be working if I use multiple proxy options:
If I use |
So, I did some digging and the following is the issue:
Because of this, my HTTP_X_FORWARDED_FOR contains 2 IPs. In the previous version of TrustedProxies, this could be solved with: In version 4, Any suggestions are welcome. |
Ah, rubber ducky debugging strikes again! Using the following results in a wildcard for all proxies:
|
@MichMich thanks, I couldn't find anywhere, what is the danger of just trusting all ips? I am using cloudflare, and when user is using google date saver, I am also getting double ip list, but always the google one is used(HTTP_X_FORWARDED_FOR look like 0.0.0.0,1.1.1.1) where I couldn't get a list of all google ip address to trust them |
@MichMich you're my hero! Been stewing on this same issue for multiple days. Thank you! |
@MichMich Thanks! That solved my problem. If you're using '0.0.0.0/0' (and maybe it needs Laravel 5.6?) you don't need to use this package at all.
and remove the TrustProxies middleware from your stack. |
@MichMich Thank you! You saved my day. I spent literally 2h searching why a dockerized Laravel app was always generating http instead of https urls. |
Keep in mind this isn't very secure since it allows you to spoof the original IP address. |
I created a package that will "replace" the |
This reinstates the behaviour originally present in fideveloper/trustedproxy where setting ** as the value for app.trustedProxies would allow all proxies vs * which would only allow the most recent one in a chain of proxies (as determined by $_SERVER['REMOTE_ADDR']). See fideloper/TrustedProxy@6018dfb for when & why it was originally added. The '**' wildcard was removed in v4 of that package (fideloper/TrustedProxy@1d09591) with no explanation and was never added back in when Laravel merged it into the core in laravel/framework#38295. This causes problems for environments where you have multiple proxies in a chain (i.e. Amazon CloudFront in front of Amazon ELB). These problems are documented in fideloper/TrustedProxy#115 & fideloper/TrustedProxy#107, and spawned fideloper/TrustedProxy#142 & https://github.com/ge-tracker/laravel-vapor-trusted-proxies to resolve them. Ultimately, this commit serves to reintroduce the original behaviour of fideveloper/trustproxies v3 and make it so that you can use `**` as the value for app.trustProxies in order to get the correct client IP address when running Winter on Laravel Vapor.
Our setup has multiple LB IP addresses, first a local one 10.* and then a public one 130.*. Lastly the users IP. This means that TrustedProxy should filter out 10.* and 130.*, but no matter what I do, it only filters out the first IP.
Everything worked correctly in version 3.*, but after upgrading to 4.*, it stopped working. Doesn't TrustedProxy support multiple layers of load balancers anymore?
Our environment is Google Cloud Platform with Laravel 5.6 and PHP 7.1.
The text was updated successfully, but these errors were encountered: