Testing prefix forwarding configs to fix livewire upload bug
This commit is contained in:
parent
82bb4969b8
commit
1670da55e9
35
app/Http/Middleware/ApplyForwardedPrefix.php
Normal file
35
app/Http/Middleware/ApplyForwardedPrefix.php
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ApplyForwardedPrefix
|
||||
{
|
||||
public function handle(Request $request, Closure $next)
|
||||
{
|
||||
$prefix = "/hosp";
|
||||
|
||||
if ($prefix) {
|
||||
// Normalize prefix to "/hosp" (no trailing slash)
|
||||
$prefix = '/' . ltrim($prefix, '/');
|
||||
$prefix = rtrim($prefix, '/');
|
||||
|
||||
// If Apache stripped /hosp before proxying, Laravel sees "/livewire/..."
|
||||
// Re-inject the prefix into REQUEST_URI so URL generation/signing aligns with the browser URL.
|
||||
$uri = $request->server->get('REQUEST_URI'); // includes query string
|
||||
if (is_string($uri) && $uri !== '' && !str_starts_with($uri, $prefix . '/')) {
|
||||
$request->server->set('REQUEST_URI', $prefix . $uri);
|
||||
}
|
||||
|
||||
// Help Symfony compute the base URL.
|
||||
$scriptName = $request->server->get('SCRIPT_NAME') ?: '';
|
||||
if ($scriptName !== '' && !str_starts_with($scriptName, $prefix . '/')) {
|
||||
$request->server->set('SCRIPT_NAME', $prefix . $scriptName);
|
||||
}
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
|
|
@ -3,6 +3,7 @@
|
|||
use Illuminate\Foundation\Application;
|
||||
use Illuminate\Foundation\Configuration\Exceptions;
|
||||
use Illuminate\Foundation\Configuration\Middleware;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
return Application::configure(basePath: dirname(__DIR__))
|
||||
->withRouting(
|
||||
|
|
@ -12,7 +13,13 @@
|
|||
)
|
||||
->withMiddleware(function (Middleware $middleware) {
|
||||
//
|
||||
$middleware->trustProxies(at: '172.16.121.9');
|
||||
$middleware->trustProxies(
|
||||
at: '*', // or ['127.0.0.1', '::1'] / your proxy IP(s)
|
||||
headers: Request::HEADER_X_FORWARDED_FOR |
|
||||
Request::HEADER_X_FORWARDED_HOST |
|
||||
Request::HEADER_X_FORWARDED_PORT |
|
||||
Request::HEADER_X_FORWARDED_PROTO
|
||||
);;
|
||||
})
|
||||
->withExceptions(function (Exceptions $exceptions): void {
|
||||
//
|
||||
|
|
|
|||
15
hosp.conf
Normal file
15
hosp.conf
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
Listen 25120
|
||||
|
||||
<VirtualHost 127.0.0.1:25120>
|
||||
ServerName jedi.msya.gov.tt
|
||||
DocumentRoot /var/www/html/hosp_2025/public
|
||||
|
||||
<Directory /var/www/html/hosp_2025/public>
|
||||
AllowOverride All
|
||||
Require all granted
|
||||
Options FollowSymLinks
|
||||
</Directory>
|
||||
|
||||
ErrorLog /var/log/httpd/hosp_2025_error.log
|
||||
CustomLog /var/log/httpd/hosp_2025_access.log combined
|
||||
</VirtualHost>
|
||||
Loading…
Reference in a new issue