allow to run this behind a reverse proxy

Signed-off-by: szaimen <szaimen@e.mail.de>
This commit is contained in:
szaimen 2021-12-08 18:12:56 +01:00
parent 704c4ad331
commit 6e9261f306
10 changed files with 84 additions and 9 deletions

View file

@ -148,8 +148,16 @@ class ConfigurationManager
// Get Instance ID
$instanceID = $this->GetSecret('INSTANCE_ID');
// set protocol
$port = $this->GetApachePort();
if ($port !== '443') {
$protocol = 'https://';
} else {
$protocol = 'http://';
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,'http://' . $domain . ':443');
curl_setopt($ch, CURLOPT_URL, $protocol . $domain . ':443');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = (string)curl_exec($ch);
# Get rid of trailing \n
@ -232,6 +240,29 @@ class ConfigurationManager
$this->WriteConfig($config);
}
public function GetApachePort() : string {
$port = getenv('APACHE_PORT');
if ($port === false) {
$config = $this->GetConfig();
if (!isset($config['apache_port']) || $config['apache_port'] === '') {
$config['apache_port'] = '443';
}
return $config['apache_port'];
} else {
if(file_exists(DataConst::GetConfigFile())) {
$config = $this->GetConfig();
if (!isset($config['apache_port'])) {
$config['apache_port'] = '';
}
if ($port !== $config['apache_port']) {
$config['apache_port'] = $port;
$this->WriteConfig($config);
}
}
return $port;
}
}
/**
* @throws InvalidSettingConfigurationException
*/