]> git.immae.eu Git - github/shaarli/Shaarli.git/commitdiff
Merge pull request #1025 from ArthurHoaro/hotfix/proxy-443
authorArthurHoaro <arthur@hoa.ro>
Sun, 3 Dec 2017 11:46:43 +0000 (12:46 +0100)
committerGitHub <noreply@github.com>
Sun, 3 Dec 2017 11:46:43 +0000 (12:46 +0100)
Force HTTPS if the original port is 443 behind a reverse proxy

1  2 
application/HttpUtils.php

index ec54dcd4faa78a92bd3fb6533b7c4f9a6b608776,c6181df44d3938842067f02d589b9253839b2f3e..c9371b55c5cc6ddacd9a888984889a466075b63a
@@@ -76,7 -76,7 +76,7 @@@ function get_http_response($url, $timeo
      curl_setopt($ch, CURLOPT_USERAGENT,         $userAgent);
  
      // Max download size management
 -    curl_setopt($ch, CURLOPT_BUFFERSIZE,        1024);
 +    curl_setopt($ch, CURLOPT_BUFFERSIZE,        1024*16);
      curl_setopt($ch, CURLOPT_NOPROGRESS,        false);
      curl_setopt($ch, CURLOPT_PROGRESSFUNCTION,
          function($arg0, $arg1, $arg2, $arg3, $arg4 = 0) use ($maxBytes)
@@@ -302,6 -302,13 +302,13 @@@ function server_url($server
                  $port = $server['HTTP_X_FORWARDED_PORT'];
              }
  
+             // This is a workaround for proxies that don't forward the scheme properly.
+             // Connecting over port 443 has to be in HTTPS.
+             // See https://github.com/shaarli/Shaarli/issues/1022
+             if ($port == '443') {
+                 $scheme = 'https';
+             }
              if (($scheme == 'http' && $port != '80')
                  || ($scheme == 'https' && $port != '443')
              ) {