Files
edubox/prestashop-image/defines_custom.inc.php
EduBox Dev 73b561ed33 fix(prestashop): image edubox-prestashop fonctionne en local et derrière proxy
- edubox-tools.patch : getShopDomain/Ssl conservent les ports non standards
- edubox-configuration.patch : PS_SHOP_DOMAIN, _PS_BASE_URL_, PS_SSL_ENABLED… résolus dynamiquement
- edubox-shop-getbaseurl.patch : Shop::getBaseURL() utilise le host de la requête
- edubox-shopurl.patch : getMainShopDomain conserve les ports non standards
- edubox-clear-cache-init.sh : vidage des caches à chaque démarrage
- seed.ts : passage au tag 9-edubox-9
- README mis à jour avec les nouveaux patches
2026-06-23 16:39:12 +00:00

35 lines
1.3 KiB
PHP

<?php
/**
* EduBox reverse proxy normalisation for PrestaShop 9 running behind the
* EduBox dynamic-public-domain resolver.
*
* The official PrestaShop 9 + PHP 8.5 + Apache image has a bug where
* X-Forwarded-* headers are exposed to PHP as arrays whose value is the
* header name. getenv() returns the correct string, so we use it to
* reconstruct $_SERVER entries used by Tools::getHttpHost/ShopDomainSSL.
*/
if ($val = getenv('HTTP_X_FORWARDED_HOST')) {
$_SERVER['HTTP_X_FORWARDED_HOST'] = $val;
}
if ($val = getenv('HTTP_X_FORWARDED_PROTO')) {
$_SERVER['HTTP_X_FORWARDED_PROTO'] = $val;
}
// Apache/PHP 8.5 sometimes corrupts HTTP_HOST into an array; fall back safely.
if (!empty($_SERVER['HTTP_HOST']) && is_array($_SERVER['HTTP_HOST'])) {
$_SERVER['HTTP_HOST'] = !empty($_SERVER['SERVER_NAME']) && !is_array($_SERVER['SERVER_NAME'])
? $_SERVER['SERVER_NAME']
: (getenv('HTTP_X_FORWARDED_HOST') ?: 'localhost');
}
if (!empty($_SERVER['HTTPS']) && is_array($_SERVER['HTTPS'])) {
$_SERVER['HTTPS'] = 'off';
}
// Tell Symfony to trust the EduBox resolver so $request->isSecure() and
// $request->getHost() honour X-Forwarded-* headers.
putenv('PS_TRUSTED_PROXIES=127.0.0.1,REMOTE_ADDR');
$_SERVER['PS_TRUSTED_PROXIES'] = '127.0.0.1,REMOTE_ADDR';
$_ENV['PS_TRUSTED_PROXIES'] = '127.0.0.1,REMOTE_ADDR';