Skip to content

Commit d37803c

Browse files
committed
Add support for scraping proxy
1 parent 6609275 commit d37803c

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
# v5.11.0
2+
## New
3+
- Added `SCRAPING_HTTP_PROXY` env variable
4+
- You can now set an HTTP proxy for scraping requests
5+
- Example value: `http://username:password@proxyserver:port`
6+
- Added `SCRAPING_CLIENT_CERT` env variable
7+
- You can now set a client certificate for scraping requests
8+
- Example value: `/var/www/cocktails/storage/bar-assistant/my-cert.pem`
9+
110
# v5.10.0
211
## New
312
- Added `locked_user_cocktails` filter to cocktails endpoint

app/Providers/AppServiceProvider.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Illuminate\Support\Facades\Log;
99
use Illuminate\Support\Facades\Cache;
1010
use Illuminate\Support\Facades\Event;
11+
use Illuminate\Support\Facades\Http;
1112
use Illuminate\Support\Facades\Redis;
1213
use Illuminate\Support\ServiceProvider;
1314

@@ -52,6 +53,18 @@ public function boot()
5253
}
5354
});
5455

56+
if (config('bar-assistant.scraping_client.proxy') !== null) {
57+
$options = [
58+
'proxy' => config('bar-assistant.scraping_client.proxy'),
59+
];
60+
61+
if (config('bar-assistant.scraping_client.cert')) {
62+
$options['verify'] = config('bar-assistant.scraping_client.cert');
63+
}
64+
65+
Http::globalOptions($options);
66+
}
67+
5568
Event::listen(function (\SocialiteProviders\Manager\SocialiteWasCalled $event) {
5669
$event->extendSocialite('authentik', \SocialiteProviders\Authentik\Provider::class);
5770
$event->extendSocialite('authelia', \SocialiteProviders\Authelia\Provider::class);

config/bar-assistant.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,9 @@
7474
'enable_feeds' => (bool) env('ENABLE_FEEDS', false),
7575

7676
'enable_password_login' => (bool) env('ENABLE_PASSWORD_LOGIN', true),
77+
78+
'scraping_client' => [
79+
'proxy' => env('SCRAPING_HTTP_PROXY', null),
80+
'cert' => env('SCRAPING_CLIENT_CERT', null),
81+
],
7782
];

0 commit comments

Comments
 (0)