From 4c0e5674eb42c71dc74d1a7d1afb6c1668d64bee Mon Sep 17 00:00:00 2001 From: Phu Hoang Date: Thu, 17 Nov 2016 20:03:05 +0700 Subject: [PATCH 1/2] Correct varnish v3 template --- .../Model/Varnish/Configurator/Abstract.php | 13 ++++++++++++- .../Nexcessnet/Turpentine/misc/version-3.vcl | 8 ++++---- 2 files changed, 16 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 77e4ec675..f83c1bfd4 100644 --- a/app/code/community/Nexcessnet/Turpentine/Model/Varnish/Configurator/Abstract.php +++ b/app/code/community/Nexcessnet/Turpentine/Model/Varnish/Configurator/Abstract.php @@ -910,11 +910,22 @@ protected function _vcl_sub_https_redirect_fix() { $baseUrl = str_replace(array('http://','https://'), '', $baseUrl); $baseUrl = rtrim($baseUrl,'/'); - $tpl = << Date: Thu, 17 Nov 2016 20:49:10 +0700 Subject: [PATCH 2/2] Migrate vcl_synth subroutine for Varnish v4 --- .../Model/Varnish/Configurator/Abstract.php | 37 +++++++++++++++++++ .../Nexcessnet/Turpentine/misc/version-4.vcl | 8 ---- 2 files changed, 37 insertions(+), 8 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 f83c1bfd4..f539e2b41 100644 --- a/app/code/community/Nexcessnet/Turpentine/Model/Varnish/Configurator/Abstract.php +++ b/app/code/community/Nexcessnet/Turpentine/Model/Varnish/Configurator/Abstract.php @@ -969,6 +969,40 @@ protected function _vcl_sub_synth() 'vcl_synth_content' => Mage::getStoreConfig('turpentine_vcl/maintenance/custom_vcl_synth'))); } + /** + * vcl_synth for fixing https + * + * @return string + */ + protected function _vcl_sub_synth_https_fix() + { + $tpl = $this->_vcl_sub_synth(); + + if(!$tpl){ + $tpl = <<_vcl_sub_https_redirect_fix(); + if(Mage::getStoreConfig('turpentine_varnish/servers/version') == '4.0'){ + $vars['vcl_synth'] = $this->_vcl_sub_synth_https_fix(); + } } foreach (array('','top') as $position) { diff --git a/app/code/community/Nexcessnet/Turpentine/misc/version-4.vcl b/app/code/community/Nexcessnet/Turpentine/misc/version-4.vcl index efef43060..5b5758b8d 100644 --- a/app/code/community/Nexcessnet/Turpentine/misc/version-4.vcl +++ b/app/code/community/Nexcessnet/Turpentine/misc/version-4.vcl @@ -102,14 +102,6 @@ sub generate_session_expires { {{generate_session_end}} ## Varnish Subroutines -sub vcl_synth { - if (resp.status == 750) { - set resp.status = 301; - set resp.http.Location = "https://" + req.http.host + req.url; - return(deliver); - } -} - sub vcl_init { {{directors}} }