I'm trying to configure mercurial access using Apache http.
It requires authentication. My /etc/apache2/sites-enabled/mercurial
looks like this:
NameVirtualHost *:8080
<VirtualHost *:8080>
UseCanonicalName Off
ServerAdmin webmaster@localhost
AddHandler cgi-script .cgi
ScriptAliasMatch ^(.*) /usr/lib/cgi-bin/hgwebdir.cgi/$1
</VirtualHost>
Every tutorial I read on the internet tells me to insert these lines:
AuthType Basic
AuthUserFile /usr/local/etc/httpd/users
But when I do it I get the following error:
# /etc/init.d/apache2 reload
Syntax error on line 8 of /etc/apache2/sites-enabled/mercurial:
AuthType not allowed here
My distro is a customized Ubuntu called Turnkey Linux Redmine
You should place this inside a Location directive:
I am running Apache2 on ubuntu 10.04 — same problem and thanks for the solution. I found that I had to put the configuration in
/etc/apache2/apache2.conf
You can generate the username and password using htpasswd. New file:
To append to existing file:
You can protect a Location or a Directory. For a Directory add something like:
You can also add
Deny
andAllow
directives for a finer control.It sounds like you're specifying the authentication settings within the
VirtualHost
. Typically, these settings are specified under theDirectory
directive.You could also use
.htaccesss
files, but specifying in the Apache conf is a good default, as it has less exposure.Apache Documentation
I'm running Apache2 on ubuntu 10.10. I've been having problems with all the solutions above, but this worked well (from apache docs):
The biggest difference from the answers above seems to be the AuthBasicProvider directive set to "file" and the Require directive including the "user" bit before the actual username.
Hope this helps someone.
We are running a memory optimised version of apache, and encountered this problem.
This was due to the following line not being present in the apache configuration: