Added support for proxy_url to enable GPM behind proxy servers #639

This commit is contained in:
Andy Miller
2016-01-27 17:15:39 -07:00
parent 7e20ef5dd6
commit b8437fbd01
2 changed files with 16 additions and 0 deletions

View File

@@ -4,6 +4,7 @@ default_locale: # Default locale (defaults to system
param_sep: ':' # Parameter separator, use ';' for Apache on windows
wrapped_site: false # For themes/plugins to know if Grav is wrapped by another platform
reverse_proxy_setup: false # Running in a reverse proxy scenario with different webserver ports than proxy
proxy_url: # Configure a manual proxy URL for GPM
languages:
supported: [] # List of languages supported. eg: [en, fr, de]

View File

@@ -2,9 +2,12 @@
namespace Grav\Common\GPM;
use Grav\Common\Utils;
use Grav\Common\GravTrait;
class Response
{
use GravTrait;
/**
* The callback for the progress
*
@@ -192,6 +195,12 @@ class Response
$options = $args[1];
$callback = $args[2];
// if proxy set add that
$proxy_url = self::getGrav()['config']->get('system.proxy_url');
if ($proxy_url) {
$options['fopen']['proxy'] = $proxy_url;
}
if ($callback) {
$options['fopen']['notification'] = ['self', 'progress'];
}
@@ -246,6 +255,12 @@ class Response
);
}
// if proxy set add that
$proxy_url = self::getGrav()['config']->get('system.proxy_url');
if ($proxy_url) {
curl_setopt($ch, CURLOP_PROXY, $proxy_url);
}
// no open_basedir set, we can proceed normally
if (!ini_get('open_basedir')) {
curl_setopt_array($ch, $options['curl']);