biigle / core

:large_blue_circle: Application core of BIIGLE
https://biigle.de
GNU General Public License v3.0
12 stars 15 forks source link

Implement proxy configuration #59

Closed mzur closed 7 years ago

mzur commented 7 years ago

Some hosts might require a special proxy configuration to be able to make outgoing HTTP requests. With remote transects, outgoing HTTP requests are a requirement for BIIGLE.

Add a new config/http.php file with the following proxy settings:

'proxy' => [
    'host' => null,
    'port' => null,
],

Use these settings to set the proxy in the AppServiceProvider like this:

stream_context_set_default([
   'http' => [
      'proxy' => 'tcp://HOST:PORT',
      'request_fulluri' => true
   ]
]);

Maybe this makes the extra proxy settings of the SOAP client of the label trees module obsolete.

Also, check if GuzzleHttp really is a requirement. We only need id for remote transect URL validation now. Maybe native PHP functions can be used for this, too. One plus for Guzzle is better testability.

Guzzle is not affected by the above settings, though, since it uses cURL if it is installed. Maybe set global cURL options, too, or not use Guzzle.

Once finished, remove the workaround in the Cebitec instance.

mzur commented 7 years ago

I found a better solution: Guzzle respects the HTTP_PROXY and HTTPS_PROXY environment variables. These can be set in the .env file. The stream_context_set_default configuration then is done only if the HTTP_PROXY environment variable is set. This configures both Guzzle and readfile() etc. correctly with a simple change in the .env file.