Files
hotel/docker/set-domain.php
DanielS 26260d0d35 Add set-domain.php; setup applies SHOP_DOMAIN/QLO_SSL on every run
QloApps redirects every request to the domain stored in the DB, so a
wrong domain or HTTPS without TLS in front ends in ERR_SSL_PROTOCOL_ERROR.
docker/set-domain.php updates PS_SHOP_DOMAIN(_SSL), shop_url, SSL flags
and .htaccess; the setup script now calls it with the .env values, so
editing .env and re-running fixes the domain. Troubleshooting table in
docker/TESTSERVER.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 00:54:00 +01:00

37 lines
1.4 KiB
PHP

<?php
/**
* Set the shop's host name and HTTPS mode (QloApps stores both in the database and
* redirects every request to that host).
* docker compose exec -u www-data app php docker/set-domain.php <host[:port]> <ssl 0|1>
* Examples:
* php docker/set-domain.php hotel-test.example.de 1 (behind nginx with HTTPS)
* php docker/set-domain.php 192.168.1.50:8080 0 (direct LAN test, no nginx)
*/
if (PHP_SAPI !== 'cli') {
exit("CLI only\n");
}
if ($argc < 3 || !in_array($argv[2], array('0', '1'), true)) {
fwrite(STDERR, "Usage: php docker/set-domain.php <host[:port]> <ssl 0|1>\n");
exit(1);
}
$domain = preg_replace('#^https?://#i', '', rtrim(trim($argv[1]), '/'));
$ssl = (int)$argv[2];
if (!preg_match('/^[A-Za-z0-9.-]+(:\d+)?$/', $domain)) {
fwrite(STDERR, "Invalid host: $domain\n");
exit(1);
}
define('_PS_ADMIN_DIR_', __DIR__);
require __DIR__.'/../config/config.inc.php';
Configuration::updateValue('PS_SHOP_DOMAIN', $domain);
Configuration::updateValue('PS_SHOP_DOMAIN_SSL', $domain);
Configuration::updateValue('PS_SSL_ENABLED', $ssl);
Configuration::updateValue('PS_SSL_ENABLED_EVERYWHERE', $ssl);
Db::getInstance()->update('shop_url', array('domain' => pSQL($domain), 'domain_ssl' => pSQL($domain)), 'main = 1');
Tools::generateHtaccess();
Tools::clearSmartyCache();
Tools::clearCache();
echo 'Shop URL: '.($ssl ? 'https' : 'http').'://'.$domain."/\n";