2016-11-16 2 views
0

Apache와 함께 Laravel 5.3 앱에 대한 액세스를 제한하려고합니다.Laravel .htaccess rewrite and apache2 위치 지시문

내 응용 프로그램은 내부적으로 사용할 수 있지만 다양한 외부 소스에서 포스트 백을 수신합니다. 내부 요청을 내부 요청에서 알 수 있도록 NAT가 비활성화 된 포트 포워딩이 있습니다.

example.com/api/external/ ...이 URL 인 경우를 제외하고 모든 URL의 403이 표시되어야합니다. 나는 외부 주소에서 모든 URL에 액세스 할 때마다

<Directory /var/www/mailer/public/> 
      Options Indexes FollowSymLinks 
      AllowOverride All 
      Require all granted 
    </Directory> 

    <Location /> 
      Order deny,allow 
      deny from all 
      allow from 10.64.1.0/24 
      allow from 10.64.20.0/24 
    </Location> 

    <Location /api/external/smsPost> 
      Allow from all 
    </Location> 

난 아직도 허용에 403를 얻을 htaccess로 다음 (Laravel 5.3의 기본값)

<IfModule mod_rewrite.c> 
<IfModule mod_negotiation.c> 
    Options -MultiViews 
</IfModule> 

RewriteEngine On 

# Redirect Trailing Slashes If Not A Folder... 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)/$ /$1 [L,R=301] 

# Handle Front Controller... 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule^index.php [L] 

# Handle Authorization Header 
RewriteCond %{HTTP:Authorization} . 
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] 

내 가상 호스트 설정을 위치.

You don't have permission to access /index.php on this server. 

나는 그것이 htaccess로하고이 목적을 위해 작동하지 않는 위치 지시자에 문제가 있음도 example.com/api/external/smsPost에 /index.php 때문에 생각합니다. 이 지시어에 필요한 것을 얻을 수있는 방법이 있습니까?

감사합니다.

답변

0

왜 laravel 미들웨어를 사용하고 제한된 경로에 바인딩합니까?

public function handle($request, Closure $next) 
{ 

    if(Route::getCurrentRoute()->getPath() == "api/external/") 
      return response('You don't have permission to access /index.php on this server.', 403); 

    // return the $next closure, so other Middlewares can run 
    return $next($request); 
}