From 70613dfe34be9b736ca1b9b4a8489d29bfe9ba6d Mon Sep 17 00:00:00 2001 From: Peter Halassek Date: Wed, 1 Feb 2017 17:33:39 +0100 Subject: [PATCH] if probe url includes a https we set the appropriate header, that magento doesn't replies with a redirect but the correct status code. --- .../Model/Varnish/Configurator/Abstract.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/app/code/community/Nexcessnet/Turpentine/Model/Varnish/Configurator/Abstract.php b/app/code/community/Nexcessnet/Turpentine/Model/Varnish/Configurator/Abstract.php index d40efe3ea..c4219364f 100644 --- a/app/code/community/Nexcessnet/Turpentine/Model/Varnish/Configurator/Abstract.php +++ b/app/code/community/Nexcessnet/Turpentine/Model/Varnish/Configurator/Abstract.php @@ -746,13 +746,18 @@ protected function _vcl_get_probe($probeUrl) { .probe = { .request = "GET {{probe_path}} HTTP/1.1" - "Host: {{probe_host}}" + "Host: {{probe_host}}"{{probe_https}} "Connection: close"; } EOS; + $additionalHeader=''; + if ($urlParts['scheme']==='https'){ + $additionalHeader="\n \"X-Forwarded-Proto: https\""; + } $vars = array( - 'probe_host' => $urlParts['host'], - 'probe_path' => $urlParts['path'] + 'probe_host' => $urlParts['host'], + 'probe_path' => $urlParts['path'], + 'probe_https' => $additionalHeader ); return $this->_formatTemplate($tpl, $vars); } @@ -910,7 +915,7 @@ protected function _vcl_sub_https_redirect_fix() { $baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB); $baseUrl = str_replace(array('http://', 'https://'), '', $baseUrl); $baseUrl = rtrim($baseUrl, '/'); - + switch (Mage::getStoreConfig('turpentine_varnish/servers/version')) { case 4.0: case 4.1: @@ -1085,7 +1090,7 @@ protected function _getTemplateVars() { // set the vcl_error from Magento database $vars['vcl_synth'] = $this->_vcl_sub_synth(); } - + if (Mage::getStoreConfig('turpentine_varnish/general/https_redirect_fix')) { $vars['https_redirect'] = $this->_vcl_sub_https_redirect_fix(); if (Mage::getStoreConfig('turpentine_varnish/servers/version') == '4.0' || Mage::getStoreConfig('turpentine_varnish/servers/version') == '4.1') {