Skip to content

Commit d0b50fe

Browse files
authored
fix: fix laravel cloudflare proxy (#6264)
1 parent fefa799 commit d0b50fe

File tree

7 files changed

+75
-198
lines changed

7 files changed

+75
-198
lines changed

app/Http/Middleware/TrustProxies.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ class TrustProxies extends Middleware
1313
*/
1414
protected function proxies()
1515
{
16-
return config('app.trust_proxies');
16+
return config('app.trust_proxies') ?? $this->proxies;
1717
}
1818
}

app/Providers/AppServiceProvider.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,10 @@
1515
use Illuminate\Support\ServiceProvider;
1616
use Illuminate\Cache\RateLimiting\Limit;
1717
use Illuminate\Validation\Rules\Password;
18-
use Monicahq\Cloudflare\LaravelCloudflare;
1918
use Illuminate\Support\Facades\RateLimiter;
2019
use Illuminate\Auth\Notifications\VerifyEmail;
2120
use Werk365\EtagConditionals\EtagConditionals;
2221
use Illuminate\Auth\Notifications\ResetPassword;
23-
use Monicahq\Cloudflare\Facades\CloudflareProxies;
2422

2523
class AppServiceProvider extends ServiceProvider
2624
{
@@ -114,10 +112,6 @@ public function boot()
114112
return sha1($url);
115113
});
116114
});
117-
118-
LaravelCloudflare::getProxiesUsing(function (): array {
119-
return config('app.cloudflare') ? CloudflareProxies::load() : [];
120-
});
121115
}
122116

123117
/**

composer.lock

Lines changed: 11 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/app.php

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -151,16 +151,6 @@
151151

152152
'trust_proxies' => env('APP_TRUSTED_PROXIES', env('APP_TRUST_PROXIES')),
153153

154-
/*
155-
|--------------------------------------------------------------------------
156-
| Enable cloudflare trusted proxies
157-
|--------------------------------------------------------------------------
158-
|
159-
| Enable to trust cloudflare proxies.
160-
|
161-
*/
162-
'cloudflare' => (bool) env('APP_TRUSTED_CLOUDFLARE', false),
163-
164154
/*
165155
|--------------------------------------------------------------------------
166156
| Autoloaded Service Providers

config/debugbar.php

Lines changed: 0 additions & 170 deletions
This file was deleted.

config/laravelcloudflare.php

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<?php
2+
3+
return [
4+
5+
/*
6+
|--------------------------------------------------------------------------
7+
| Enable or disable the middleware proxy and the reload
8+
|--------------------------------------------------------------------------
9+
|
10+
| If you set it to false, the middleware and the reload command will never
11+
| be executed.
12+
|
13+
*/
14+
15+
'enabled' => (bool) env('LARAVEL_CLOUDFLARE_ENABLED', env('APP_TRUSTED_CLOUDFLARE', false)),
16+
17+
/*
18+
|--------------------------------------------------------------------------
19+
| Name of the cache to store values of the proxies
20+
|--------------------------------------------------------------------------
21+
|
22+
| This value is the key used in the cache (table, redis, etc.) to store the
23+
| values.
24+
|
25+
*/
26+
27+
'cache' => 'cloudflare.proxies',
28+
29+
/*
30+
|--------------------------------------------------------------------------
31+
| Cloudflare main url
32+
|--------------------------------------------------------------------------
33+
|
34+
| This is the url for the cloudflare api.
35+
|
36+
*/
37+
38+
'url' => 'https://www.cloudflare.com',
39+
40+
/*
41+
|--------------------------------------------------------------------------
42+
| Cloudflare uri for ipv4 ips response
43+
|--------------------------------------------------------------------------
44+
|
45+
| This is the path to get the values of ipv4 ips from Cloudflare.
46+
|
47+
*/
48+
49+
'ipv4-path' => 'ips-v4',
50+
51+
/*
52+
|--------------------------------------------------------------------------
53+
| Cloudflare uri for ipv6 ips response
54+
|--------------------------------------------------------------------------
55+
|
56+
| This is the path to get the values of ipv6 ips from Cloudflare.
57+
|
58+
*/
59+
60+
'ipv6-path' => 'ips-v6',
61+
62+
];

phpunit.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,5 +72,6 @@
7272
<env name="MAIL_PORT" value=""/>
7373
<env name="MAIL_ENCRYPTION" value=""/>
7474
<env name="APP_EMAIL_NEW_USERS_NOTIFICATION" value=""/>
75+
<env name="LARAVEL_CLOUDFLARE_ENABLED" value="false"/>
7576
</php>
7677
</phpunit>

0 commit comments

Comments
 (0)