2014-05-14 2 views
1

기본 인증을 사용하는 Apache VHOST가있는 서버에서 서버 상태가 작동하려고합니다. 주요 httpd.conf 설정 파일에서 VHOST 기본 인증이 아파치 서버 상태와 충돌합니다.

I는 서버 상태 세트를 가지고 :

<Location /server-status> 
    SetHandler server-status 
    Order deny,allow 
    Deny from all 
    Allow from 127.0.0.1 10.10.1.246 
</Location> 

내가 호스트의 서버 상태에 GET 할 경우 I는 사용자 이름과 암호를 입력하라는 메시지가 얻을 :

[[email protected] apache2]# GET http://$(hostname -i)/server-status 
Enter username for Restricted Area at 10.10.1.246:80: 

사용자 이름과 암호를 입력하면 GET 명령에서 서버 상태 페이지를 볼 수 있습니다. 그러나 문제는 이것이 모니터링을 위해 자동화되어야한다는 것입니다. 그리고 감시 부서는 사용자 이름과 암호로 보호되는 경우이 호스트를 모니터 할 수 없으며 감시하지 않을 것입니다.

그리고 나는 거기에 서버 상태 가상 호스트의 conf를 이동하는 경우 나 서버 상태 페이지 얻을 수 있습니다 :

[[email protected]]# GET http://$(hostname -i)/server-status | head -10 
<? 
    require('_config.php'); 
    $contactsData = simplexml_load_file(USE_CMS ? WEB_ROOT . 'wordpress/contacts' :  'data/contacts.xml'); 
    $downloadsData = simplexml_load_file(USE_CMS ? WEB_ROOT . 'wordpress/downloads' :  'data/downloads.xml'); 
?> 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" 
"http://www.w3.org/TR/html4/strict.dtd"> 

문제는 내가 두 세계의 최고를 필요로입니다. 서버에 기본 인증이있는 사이트가 필요하며 서버 상태를 사용 가능하게 설정해야합니다.

나는 기본적인 인증과 같이있는 가상 호스트 서버의 상태를 분리하기위한 노력의 일환으로 그 자체가 가상 호스트 구성의 서버 상태를 제공함으로써이 문제를 해결하려 :

<VirtualHost *> 
ServerName host.west.company.com 
<Location /server-status> 
SetHandler server-status 
Order deny,allow 
Deny from all 
Allow from 127.0.0.1 10.10.1.246 
</Location> 
</VirtualHost> 

하지만 난 운이 없었다 거기도. 이전처럼 사용자 이름과 암호를 입력하라는 메시지 만 표시합니다.

나는 아파치 문서를 읽을 때까지 나는이 같은 문제를 했어

답변

0

: 이 http://httpd.apache.org/docs/2.2/en/vhosts/name-based.html

찾을 수 있습니다 : 가상 추가하는 경우

메인 호스트가

사라질를 호스트를 기존 웹 서버에 연결하려면 도 기존 호스트에 대한 블록을 만들어야합니다. 이 가상 호스트에 포함 된 ServerName 및 DocumentRoot는 글로벌 ServerName 및 DocumentRoot와 동일한 이어야합니다. 호스트를 먼저 구성 파일에 나열하면 기본 호스트로 작동합니다. 이 변경을하지 않을 경우

그래서, 당신은 예를 들어, 기본 웹 서버를 분실 :

#>httpd -S 
[[email protected]]# apachectl -S 
VirtualHost configuration: 
wildcard NameVirtualHosts and _default_ servers: 
*:80     is a NameVirtualHost 
     default server virtualhost.domain.com (/etc/httpd/conf/virtualhost.conf:4) 
     port 80 namevhost virtualhost.domain.com (/etc/httpd/conf/virtualhost.conf:4) 
Syntax OK 

당신처럼, 모든 기본 구성으로 (다시 기본 웹 서버를 얻을하려는 경우/서버 상태), 당신은 문서와 같은 명명 된 가상 호스트를 만들 필요가 설명 :

[[email protected] conf]# cat defaultserver.conf 

# you can't get this directive inside the <VirtualHost> tag 
ExtendedStatus On 

<VirtualHost *:80> 
    ServerAdmin [email protected] 
    ServerName default.domain.com 
    DocumentRoot "/etc/httpd/htdocs" 

    # Real-time info on requests and configuration 
    Include conf/extra/httpd-info.conf 

</VirtualHost> 

에서 마지막으로, 당신은 구성에서 먼저 기본 가상 호스트를 포함 할 필요가 :

[[email protected] conf]# cat virtualhosts.conf 
NameVirtualHost *:80 

include conf/defaultserver.conf 
include conf/virtualhost.conf 
는 아파치 서버를 다시 시작

당신은 구성의 유효성을 검사 할 수 있습니다

[[email protected]]# apachectl -S 
VirtualHost configuration: 
wildcard NameVirtualHosts and _default_ servers: 
*:80     is a NameVirtualHost 
     default server default.domain.com (/etc/httpd/conf/defaultserver.conf:4) 
     port 80 namevhost default.domain.com (/etc/httpd/conf/defaultserver.conf:4) 
     port 80 namevhost virtualhost.domain.com (/etc/httpd/conf/virtualhost.conf:4) 
Syntax OK