1
0
mirror of https://github.com/freescout-helpdesk/freescout.git synced 2025-01-31 20:11:38 +01:00

Fix installing helpdesk without HTTPS via install.sh script

This commit is contained in:
FreeScout 2023-11-03 23:33:10 -07:00
parent f21054f17f
commit 4a24df3395
3 changed files with 30 additions and 9 deletions

View File

@ -30,13 +30,8 @@ class HttpsRedirect {
{
if (\Helper::isHttps()) {
//$request->setTrustedProxies( [ $request->getClientIp() ], array_keys($this->headers));
if (//!$request->secure()
!in_array(strtolower($_SERVER['X_FORWARDED_PROTO'] ?? ''), array('https', 'on', 'ssl', '1'), true)
&& strtolower($_SERVER['HTTPS'] ?? '') != 'on'
&& ($_SERVER['HTTP_X_FORWARDED_PROTO'] ?? '') != 'https'
&& ($_SERVER['HTTP_CF_VISITOR'] ?? '') != '{"scheme":"https"}'
) {
//!$request->secure()
if (!\Helper::isCurrentUrlHttps()) {
return redirect()->secure($request->getRequestUri());
}
}

View File

@ -1773,7 +1773,33 @@ class Helper
public static function isHttps($url = '')
{
return self::getProtocol($url) == 'https';
if (\Helper::isInstaller()) {
// In the Installer we determine HTTPS from URL.
return self::isCurrentUrlHttps();
} else {
return self::getProtocol($url) == 'https';
}
}
public static function isInstaller()
{
$request_uri = $_SERVER['REQUEST_URI'] ?? '';
$request_uri = preg_replace("#\?.*#", '', $request_uri);
return strstr($request_uri, '/install/') || preg_match("#/install$#", $request_uri);
}
public static function isCurrentUrlHttps()
{
if (in_array(strtolower($_SERVER['X_FORWARDED_PROTO'] ?? ''), array('https', 'on', 'ssl', '1'), true)
|| strtolower($_SERVER['HTTPS'] ?? '') == 'on'
|| ($_SERVER['HTTP_X_FORWARDED_PROTO'] ?? '') == 'https'
|| ($_SERVER['HTTP_CF_VISITOR'] ?? '') == '{"scheme":"https"}'
) {
return true;
} else {
return false;
}
}
public static function fixProtocol($url)

View File

@ -41,7 +41,7 @@ class AppServiceProvider extends ServiceProvider
{
// Forse HTTPS if using CloudFlare "Flexible SSL"
// https://support.cloudflare.com/hc/en-us/articles/200170416-What-do-the-SSL-options-mean-
if (\Helper::getProtocol() == 'https') {
if (\Helper::isHttps()) {
// $_SERVER['HTTPS'] = 'on';
// $_SERVER['SERVER_PORT'] = '443';
$this->app['url']->forceScheme('https');