Jad*_*ias 53 httpd authentication mercurial http-authentication apache-2.2
我正在尝试使用 Apache http 配置 mercurial 访问。它需要身份验证。我的/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>
Run Code Online (Sandbox Code Playgroud)
我在互联网上阅读的每个教程都告诉我插入这些行:
AuthType Basic
AuthUserFile /usr/local/etc/httpd/users
Run Code Online (Sandbox Code Playgroud)
但是当我这样做时,我收到以下错误:
# /etc/init.d/apache2 reload
Syntax error on line 8 of /etc/apache2/sites-enabled/mercurial:
AuthType not allowed here
Run Code Online (Sandbox Code Playgroud)
我的发行版是一个定制的 Ubuntu,称为 Turnkey Linux Redmine
小智 80
你应该把它放在一个 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>
Run Code Online (Sandbox Code Playgroud)
小智 11
我在 ubuntu 10.04 上运行 Apache2 — 同样的问题,感谢您的解决方案。我发现我必须把配置放进去/etc/apache2/apache2.conf
您可以使用 htpasswd 生成用户名和密码。新文件:
$ htpasswd -c /srv/auth/.htpasswd squire
Run Code Online (Sandbox Code Playgroud)
要附加到现有文件:
$ htpasswd -b /srv/auth/.htpasswd squire2 tickleme2
Run Code Online (Sandbox Code Playgroud)
您可以保护位置或目录。对于目录添加如下内容:
<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>
Run Code Online (Sandbox Code Playgroud)
您还可以添加Deny
和Allow
指令以进行更精细的控制。
归档时间: |
|
查看次数: |
167999 次 |
最近记录: |