2015-02-04 2 views
0

이 간단한 디렉토리 액세스 규칙에 대한 도움이 필요합니다. 죄송합니다. Apache 2.4로 게임을 시작했지만 이전에는이 ​​작업을 수행하지 않았습니다.Apache 2.4 mod_auth_form에 대한 디렉토리 액세스 제어

아파치 2.4를 보호 된 리소스에 대한 로그인을 볼 수있는 단계로 구성했으며 사용자/패스를 입력하면 보호 된 리소스에 액세스 할 수 있습니다.

이제 어떻게해야 할 지 잘 모르겠지만 다음을 수행하고 싶습니다.

  1. 웹 루트는은/var/www가 설정되어
  2. 의/var/www /에서 로그인 -이 폴더로 필요하지 인증은 login.html 및 logout.html가없는 사람이 액세스 할 수 있습니다. (나는이 일을 가지고있어)
  3. /var/www - 내 애플 리케이션의 루트에있는 다른 모든 내용은 인증 후에 만 ​​액세스 할 수 있습니다. 이것은 설치 방법을 모르는 부분입니다.

내 vhost conf는 다음과 같습니다. 현재 AT

NameVirtualHost *:80 
<VirtualHost *:80> 
    ServerAdmin [email protected] 
    DocumentRoot "/var/www" 
    ServerName auth-test.ml.com 
    ErrorLog "logs/test-error_log" 
    CustomLog "logs/test-access_log" common 

<Directory "/var/www"> 
    AuthFormProvider file 
    AuthType form 
    AuthName "Reserved Area" 
    Session On 
    SessionCookieName session path=/ 
    require valid-user 

     # This is the login page 
    ErrorDocument 401 /login/index.html 

    # This is the file containing users login data 
    AuthUserFile /usr/local/apache2/auth/.htpasswd 

</Directory> 
<Directory /var/www/login> 
       Options Indexes FollowSymLinks MultiViews 
       AllowOverride None 
       Order allow,deny 
       allow from all 
    </Directory> 

</VirtualHost> 

나는 내가 login.html 페이지가 반환 볼 것으로 예상 http://example.com 같은 응용 프로그램에 액세스하지만 다음과 같은 오류 메시지가

는 :

Unauthorized 

This server could not verify that you are authorized to access the document requested. Either you supplied the wrong credentials (e.g., bad password), or your browser doesn't understand how to supply the credentials required. 

Additionally, a 401 Unauthorized error was encountered while trying to use an ErrorDocument to handle the request. 

어떻게이 일을 할 수 있습니까?

답변

0

알아 냈어. Directory를 사용하여 루트 문서에 대한 모든 사용자의 액세스를 먼저 거부하고 유효한 사용자 만 허용하는 것처럼 간단했습니다.

다른 디렉토리를 사용하여 auth 폴더에 대한 모든 액세스 권한을 엽니 다.