Apache http를 사용하여 수은 액세스를 구성하려고합니다. 인증이 필요합니다. 내 /etc/apache2/sites-enabled/mercurial
모습은 다음과 같습니다.
NameVirtualHost *:8080
<VirtualHost *:8080>
UseCanonicalName Off
ServerAdmin webmaster@localhost
AddHandler cgi-script .cgi
ScriptAliasMatch ^(.*) /usr/lib/cgi-bin/hgwebdir.cgi/$1
</VirtualHost>
인터넷에서 읽은 모든 자습서는 다음 줄을 삽입하도록 알려줍니다.
AuthType Basic
AuthUserFile /usr/local/etc/httpd/users
그러나 내가 할 때 다음과 같은 오류가 발생합니다.
# /etc/init.d/apache2 reload
Syntax error on line 8 of /etc/apache2/sites-enabled/mercurial:
AuthType not allowed here
내 배포판은 턴키 리눅스 레드 마인이라는 사용자 정의 우분투입니다
답변
이것을 Location 지시문에 배치해야합니다.
<VirtualHost *:8080>
<Location /> #the / has to be there, otherwise Apache startup fails
Deny from all
#Allow from (You may set IP here / to access without password)
AuthUserFile /usr/local/etc/httpd/users
AuthName authorization
AuthType Basic
Satisfy Any # (or all, if IPs specified and require IP + pass)
# any means neither ip nor pass
require valid-user
</Location>
...
</VirtualHost>
답변
우분투 10.04에서 Apache2를 실행 중입니다. 동일한 문제이며 솔루션에 감사드립니다. 구성을 넣어야한다는 것을 알았습니다./etc/apache2/apache2.conf
htpasswd를 사용하여 사용자 이름과 비밀번호를 생성 할 수 있습니다. 새로운 파일:
$ htpasswd -c /srv/auth/.htpasswd squire
기존 파일에 추가하려면
$ htpasswd -b /srv/auth/.htpasswd squire2 tickleme2
답변
위치 또는 디렉토리를 보호 할 수 있습니다. 디렉토리의 경우 다음과 같이 추가하십시오.
<Directory /some/dir/cgi-bin/>
Options +ExecCGI
AddHandler cgi-script .cgi
AuthType Basic
AuthName 'Private scripts'
AuthUserFile '/some/other/dir/.htpasswd'
Require valid-user
</Directory>
더 세밀한 제어를 위해 지시문을 추가 Deny
하고 Allow
지시 할 수도 있습니다 .
답변
에서 인증 설정을 지정하는 것 같습니다 VirtualHost
. 일반적으로 이러한 설정은 Directory
지시문에 지정됩니다.
.htaccesss
파일 을 사용할 수도 있지만 노출이 적기 때문에 Apache conf에서 지정하는 것이 좋습니다.
답변
우분투 10.10에서 Apache2를 실행하고 있습니다. 위의 모든 솔루션에 문제가 있었지만 아파치 문서에서 잘 작동했습니다.
<디렉토리 / var / www /> 옵션 색인 FollowSymLinks MultiViews AllowOverride All 주문 허용, 거부 모든 것을 허락하다 AuthType 기본 AuthName "제한된" AuthBasicProvider 파일 AuthUserFile / etc / users 사용자 방문자 필요 </ Directory>
위의 답변과 가장 큰 차이점은 AuthBasicProvider 지시문이 “file”로 설정되어 있고 실제 사용자 이름 앞에 “user”비트를 포함하는 Require 지시문 인 것 같습니다.
이것이 누군가를 돕기를 바랍니다.
답변
메모리 최적화 버전의 아파치를 실행하고 있는데이 문제가 발생했습니다.
이것은 아파치 구성에 다음 줄이 없기 때문입니다.
LoadModule authz_user_module modules/mod_authz_user.so