@@ 864-901 (lines=38) @@ | ||
861 | * |
|
862 | * @return string |
|
863 | */ |
|
864 | protected function _vcl_sub_maintenance_allowed_ips() { |
|
865 | if (( ! $this->_getDebugIps()) || ! Mage::getStoreConfig('turpentine_vcl/maintenance/custom_vcl_synth')) { |
|
866 | return false; |
|
867 | } |
|
868 | ||
869 | switch (Mage::getStoreConfig('turpentine_varnish/servers/version')) { |
|
870 | case 4.0: |
|
871 | $tpl = <<<EOS |
|
872 | if (req.http.X-Forwarded-For) { |
|
873 | if (req.http.X-Forwarded-For !~ "{{debug_ips}}") { |
|
874 | return (synth(999, "Maintenance mode")); |
|
875 | } |
|
876 | } |
|
877 | else { |
|
878 | if (client.ip !~ debug_acl) { |
|
879 | return (synth(999, "Maintenance mode")); |
|
880 | } |
|
881 | } |
|
882 | ||
883 | EOS; |
|
884 | break; |
|
885 | default: |
|
886 | $tpl = <<<EOS |
|
887 | if (req.http.X-Forwarded-For) { |
|
888 | if(req.http.X-Forwarded-For !~ "{{debug_ips}}") { |
|
889 | error 503; |
|
890 | } |
|
891 | } else { |
|
892 | if (client.ip !~ debug_acl) { |
|
893 | error 503; |
|
894 | } |
|
895 | } |
|
896 | EOS; |
|
897 | } |
|
898 | ||
899 | return $this->_formatTemplate($tpl, array( |
|
900 | 'debug_ips' => Mage::getStoreConfig('dev/restrict/allow_ips') )); |
|
901 | } |
|
902 | ||
903 | /** |
|
904 | * When using Varnish as front door listen on port 80 and Nginx/Apache listen on port 443 for HTTPS, the fix will keep the url parameters when redirect from HTTP to HTTPS. |
|
@@ 937-970 (lines=34) @@ | ||
934 | * |
|
935 | * @return string |
|
936 | */ |
|
937 | protected function _vcl_sub_synth() |
|
938 | { |
|
939 | if (( ! $this->_getDebugIps()) || ! Mage::getStoreConfig('turpentine_vcl/maintenance/custom_vcl_synth')) { |
|
940 | return false; |
|
941 | } |
|
942 | ||
943 | switch (Mage::getStoreConfig('turpentine_varnish/servers/version')) { |
|
944 | case 4.0: |
|
945 | $tpl = <<<EOS |
|
946 | sub vcl_synth { |
|
947 | if (resp.status == 999) { |
|
948 | set resp.status = 404; |
|
949 | set resp.http.Content-Type = "text/html; charset=utf-8"; |
|
950 | synthetic({"{{vcl_synth_content}}"}); |
|
951 | return (deliver); |
|
952 | } |
|
953 | return (deliver); |
|
954 | } |
|
955 | ||
956 | EOS; |
|
957 | break; |
|
958 | default: |
|
959 | $tpl = <<<EOS |
|
960 | sub vcl_error { |
|
961 | set obj.http.Content-Type = "text/html; charset=utf-8"; |
|
962 | synthetic {"{{vcl_synth_content}}"}; |
|
963 | return (deliver); |
|
964 | } |
|
965 | EOS; |
|
966 | } |
|
967 | ||
968 | return $this->_formatTemplate($tpl, array( |
|
969 | 'vcl_synth_content' => Mage::getStoreConfig('turpentine_vcl/maintenance/custom_vcl_synth'))); |
|
970 | } |
|
971 | ||
972 | /** |
|
973 | * vcl_synth for fixing https |