@@ 887-925 (lines=39) @@ | ||
884 | * |
|
885 | * @return string |
|
886 | */ |
|
887 | protected function _vcl_sub_maintenance_allowed_ips() { |
|
888 | if (( ! $this->_getDebugIps()) || ! Mage::getStoreConfig('turpentine_vcl/maintenance/custom_vcl_synth')) { |
|
889 | return false; |
|
890 | } |
|
891 | ||
892 | switch (Mage::getStoreConfig('turpentine_varnish/servers/version')) { |
|
893 | case 4.0: |
|
894 | case 4.1: |
|
895 | $tpl = <<<EOS |
|
896 | if (req.http.X-Forwarded-For) { |
|
897 | if (req.http.X-Forwarded-For !~ "{{debug_ips}}") { |
|
898 | return (synth(999, "Maintenance mode")); |
|
899 | } |
|
900 | } |
|
901 | else { |
|
902 | if (client.ip !~ debug_acl) { |
|
903 | return (synth(999, "Maintenance mode")); |
|
904 | } |
|
905 | } |
|
906 | ||
907 | EOS; |
|
908 | break; |
|
909 | default: |
|
910 | $tpl = <<<EOS |
|
911 | if (req.http.X-Forwarded-For) { |
|
912 | if(req.http.X-Forwarded-For !~ "{{debug_ips}}") { |
|
913 | error 503; |
|
914 | } |
|
915 | } else { |
|
916 | if (client.ip !~ debug_acl) { |
|
917 | error 503; |
|
918 | } |
|
919 | } |
|
920 | EOS; |
|
921 | } |
|
922 | ||
923 | return $this->_formatTemplate($tpl, array( |
|
924 | 'debug_ips' => Mage::getStoreConfig('dev/restrict/allow_ips') )); |
|
925 | } |
|
926 | ||
927 | /** |
|
928 | * When using Varnish on port 80 and Hitch listen on port 443 for HTTPS, the fix will set X-Forwarded-Proto to HTTPS to prevent redirect loop. |
|
@@ 1007-1041 (lines=35) @@ | ||
1004 | * |
|
1005 | * @return string |
|
1006 | */ |
|
1007 | protected function _vcl_sub_synth() |
|
1008 | { |
|
1009 | if (( ! $this->_getDebugIps()) || ! Mage::getStoreConfig('turpentine_vcl/maintenance/custom_vcl_synth')) { |
|
1010 | return false; |
|
1011 | } |
|
1012 | ||
1013 | switch (Mage::getStoreConfig('turpentine_varnish/servers/version')) { |
|
1014 | case 4.0: |
|
1015 | case 4.1: |
|
1016 | $tpl = <<<EOS |
|
1017 | sub vcl_synth { |
|
1018 | if (resp.status == 999) { |
|
1019 | set resp.status = 503; |
|
1020 | set resp.http.Content-Type = "text/html; charset=utf-8"; |
|
1021 | synthetic({"{{vcl_synth_content}}"}); |
|
1022 | return (deliver); |
|
1023 | } |
|
1024 | return (deliver); |
|
1025 | } |
|
1026 | ||
1027 | EOS; |
|
1028 | break; |
|
1029 | default: |
|
1030 | $tpl = <<<EOS |
|
1031 | sub vcl_error { |
|
1032 | set obj.http.Content-Type = "text/html; charset=utf-8"; |
|
1033 | synthetic {"{{vcl_synth_content}}"}; |
|
1034 | return (deliver); |
|
1035 | } |
|
1036 | EOS; |
|
1037 | } |
|
1038 | ||
1039 | return $this->_formatTemplate($tpl, array( |
|
1040 | 'vcl_synth_content' => Mage::getStoreConfig('turpentine_vcl/maintenance/custom_vcl_synth'))); |
|
1041 | } |
|
1042 | ||
1043 | /** |
|
1044 | * vcl_synth for fixing https |