35 lines
1.1 KiB
PHP
35 lines
1.1 KiB
PHP
<?php
|
|
// WEVIA Center Proxy — SSO gate + proxy to 10.1.0.3:5880
|
|
if (isset($_COOKIE['PHPSESSID'])) @session_id($_COOKIE['PHPSESSID']);
|
|
@session_start();
|
|
|
|
// Minimal auth check (replaces missing authentik-trust.php)
|
|
$authed = !empty($_SESSION["weval_auth"]) || !empty($_COOKIE["authentik_session"]);
|
|
|
|
if (!$authed) {
|
|
http_response_code(200);
|
|
$login = "/var/www/html/weval-login.html";
|
|
if (file_exists($login)) { readfile($login); } else { echo '<h1>Login required</h1>'; }
|
|
exit;
|
|
}
|
|
|
|
$path = preg_replace("#^/wevia-center#", "", $_SERVER["REQUEST_URI"] ?? "/");
|
|
if (!$path || $path === "") $path = "/";
|
|
|
|
$ch = curl_init("http://10.1.0.3:5880" . $path);
|
|
curl_setopt_array($ch, [
|
|
CURLOPT_RETURNTRANSFER => true,
|
|
CURLOPT_TIMEOUT => 15,
|
|
CURLOPT_FOLLOWLOCATION => true,
|
|
CURLOPT_HTTPHEADER => ["Host: 10.1.0.3:5880"],
|
|
CURLOPT_USERPWD => "weval:YacineWeval2026"
|
|
]);
|
|
$body = curl_exec($ch);
|
|
$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
|
$ct = curl_getinfo($ch, CURLINFO_CONTENT_TYPE) ?: 'text/html';
|
|
curl_close($ch);
|
|
|
|
http_response_code($code ?: 502);
|
|
header("Content-Type: $ct");
|
|
echo $body ?: '<h1>Upstream unavailable</h1>';
|