ip() is the proxy's address, so an IP allowlist would * be misleading. The real network-level control stays in the proxy. */ class RestrictAdminHost { public function handle(Request $request, Closure $next): Response { // Path-scoped and prepended to the `web` group rather than attached to // the admin route group: route middleware is reordered by Laravel's // priority list, which puts `auth` first — a guest would then be // redirected to /login and thereby learn the console exists. Running // ahead of the whole route stack makes the 404 deterministic. if (! $request->is('admin', 'admin/*')) { return $next($request); } $allowed = (array) config('admin_access.hosts', []); if ($allowed !== [] && ! in_array($request->getHost(), $allowed, true)) { abort(404); } return $next($request); } }