Laravel - artisan down / Maintenance Mode except own IP

后端 未结 6 1841
Happy的楠姐
Happy的楠姐 2021-02-14 16:38

Currently i am using Laravel5. My question is if if i use the Maintenance mode with

php artisan down

how can say \"the application is down for

6条回答
  •  孤城傲影
    2021-02-14 17:12

    Create new middleware

    app = $app;
    
            $this->request = $request;
    
        }
    
    
    
        /**
    
         * Handle an incoming request.
    
         *
    
         * @param  \Illuminate\Http\Request  $request
    
         * @param  \Closure  $next
    
         * @return mixed
    
         */
    
    
    
        public function handle($request, Closure $next)
    
        {
    
            if ($this->app->isDownForMaintenance() &&
    
                !in_array($this->request->getClientIp(), ['::1']))
    
            {
    
                throw new HttpException(503);
    
            }
    
    
    
            return $next($request);
    
        }
    
    }
    

    The '::1' is your own IP assuming your in localhost, if not the specify your IP. You can excluded multiple IP in the array. check Excluding your IP Address in Maintenance Mode (php artisan down) in Laravel 5

提交回复
热议问题