From b8437fbd019388aa2027afa5798de24b200d8fd9 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Wed, 27 Jan 2016 17:15:39 -0700 Subject: [PATCH] Added support for proxy_url to enable GPM behind proxy servers #639 --- system/config/system.yaml | 1 + system/src/Grav/Common/GPM/Response.php | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/system/config/system.yaml b/system/config/system.yaml index b5d6e875e..7da4ac679 100644 --- a/system/config/system.yaml +++ b/system/config/system.yaml @@ -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] diff --git a/system/src/Grav/Common/GPM/Response.php b/system/src/Grav/Common/GPM/Response.php index 87ba44e9b..cbd9d21be 100644 --- a/system/src/Grav/Common/GPM/Response.php +++ b/system/src/Grav/Common/GPM/Response.php @@ -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']);