@@ -910,11 +910,22 @@ protected function _vcl_sub_https_redirect_fix() {
910
910
$ baseUrl = str_replace (array ('http:// ' ,'https:// ' ), '' , $ baseUrl );
911
911
$ baseUrl = rtrim ($ baseUrl ,'/ ' );
912
912
913
- $ tpl = <<<EOS
913
+ switch (Mage::getStoreConfig ('turpentine_varnish/servers/version ' )) {
914
+ case 4.0 :
915
+ $ tpl = <<<EOS
914
916
if ( (req.http.host ~ "^(?i)www. $ baseUrl" || req.http.host ~ "^(?i) $ baseUrl") && req.http.X-Forwarded-Proto !~ "(?i)https") {
915
917
return (synth(750, ""));
916
918
}
917
919
EOS ;
920
+ break ;
921
+ default :
922
+ $ tpl = <<<EOS
923
+ if ( (req.http.host ~ "^(?i)www. $ baseUrl" || req.http.host ~ "^(?i) $ baseUrl") && req.http.X-Forwarded-Proto !~ "(?i)https") {
924
+ error 750 "https://" + req.http.host + req.url;
925
+ }
926
+ EOS ;
927
+ }
928
+
918
929
return $ tpl ;
919
930
}
920
931
@@ -958,6 +969,40 @@ protected function _vcl_sub_synth()
958
969
'vcl_synth_content ' => Mage::getStoreConfig ('turpentine_vcl/maintenance/custom_vcl_synth ' )));
959
970
}
960
971
972
+ /**
973
+ * vcl_synth for fixing https
974
+ *
975
+ * @return string
976
+ */
977
+ protected function _vcl_sub_synth_https_fix ()
978
+ {
979
+ $ tpl = $ this ->_vcl_sub_synth ();
980
+
981
+ if (!$ tpl ){
982
+ $ tpl = <<<EOS
983
+ sub vcl_synth {
984
+ if (resp.status == 750) {
985
+ set resp.status = 301;
986
+ set resp.http.Location = "https://" + req.http.host + req.url;
987
+ return(deliver);
988
+ }
989
+ }
990
+ EOS ;
991
+ }else {
992
+ $ tpl_750 = '
993
+ sub vcl_synth {
994
+ if (resp.status == 750) {
995
+ set resp.status = 301;
996
+ set resp.http.Location = "https://" + req.http.host + req.url;
997
+ return(deliver);
998
+ } ' ;
999
+
1000
+ $ tpl = str_ireplace ('sub vcl_synth { ' , $ tpl_750 , $ tpl );
1001
+ }
1002
+
1003
+ return $ tpl ;
1004
+ }
1005
+
961
1006
962
1007
963
1008
/**
@@ -1040,6 +1085,9 @@ protected function _getTemplateVars() {
1040
1085
1041
1086
if (Mage::getStoreConfig ('turpentine_varnish/general/https_redirect_fix ' )) {
1042
1087
$ vars ['https_redirect ' ] = $ this ->_vcl_sub_https_redirect_fix ();
1088
+ if (Mage::getStoreConfig ('turpentine_varnish/servers/version ' ) == '4.0 ' ){
1089
+ $ vars ['vcl_synth ' ] = $ this ->_vcl_sub_synth_https_fix ();
1090
+ }
1043
1091
}
1044
1092
1045
1093
foreach (array ('' ,'top ' ) as $ position ) {
0 commit comments