mirror of
https://github.com/getgrav/grav-plugin-admin.git
synced 2026-05-07 02:26:23 +02:00
fix(force_ssl): use scheme instead of server var (#2435)
using some proxy / load balancer may not properly set server https index, thus leading to infinite redirection on force_ssl parameter set to true
align https detection with grav-core code:
a1c116dd82/system/src/Grav/Common/Service/PagesServiceProvider.php (L72-L78)
This commit is contained in:
@@ -396,9 +396,10 @@ class AdminPlugin extends Plugin
|
||||
|
||||
// Force SSL with redirect if required
|
||||
if ($config->get('system.force_ssl')) {
|
||||
if (!isset($_SERVER['HTTPS']) || strtolower($_SERVER['HTTPS']) !== 'on') {
|
||||
$scheme = $this->uri->scheme(true);
|
||||
if ($scheme !== 'https') {
|
||||
Admin::DEBUG && Admin::addDebugMessage('Admin SSL forced on, redirect');
|
||||
$url = 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
|
||||
$url = 'https://' . $this->uri->host() . $this->uri->uri();
|
||||
$this->grav->redirect($url);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user