Here is my site file on Ubuntu server 11.10:

<IfModule mod_ssl.c>
<VirtualHost *:443>
    ServerAdmin webmaster@localhost

    DocumentRoot /var/www/mydir
    ServerAlias *.mydomain.no-ip.info
    <Directory />
            Options FollowSymLinks
            AllowOverride None
    <Directory /var/www/mydir>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride None
            Order allow,deny
            allow from all

    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    <Directory "/usr/lib/cgi-bin">
            AllowOverride None
            Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
            Order allow,deny
            Allow from all

    ErrorLog ${APACHE_LOG_DIR}/error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    CustomLog ${APACHE_LOG_DIR}/ssl_access.log combined

    Alias /doc/ "/usr/share/doc/"
    <Directory "/usr/share/doc/">
            Options Indexes MultiViews FollowSymLinks
            AllowOverride None
            Order deny,allow
            Deny from all
            Allow from ::1/128

    #   SSL Engine Switch:
    #   Enable/Disable SSL for this virtual host.
    SSLEngine on

    #   A self-signed (snakeoil) certificate can be created by installing
    #   the ssl-cert package. See
    #   /usr/share/doc/apache2.2-common/README.Debian.gz for more info.
    #   If both key and certificate are stored in the same file, only the
    #   SSLCertificateFile directive is needed.
    SSLCertificateFile    /etc/ssl/certs/ssl-cert-snakeoil.pem
    SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key

Now I wanted authorized access to directory:


I created the digest file like this:

sudo htdigest -c /etc/apache2/digest_auth users enedene

So I added the following before the <\Virtualhost>:

<Directory "/var/www/mydir/private/">
            AuthType Digest
            AuthName "Private"
            AuthDigestProvider file
            AuthUserFile /etc/apache2/digest_auth
            Require enedene

I restarted the web server and when I go to link:


I get prompted with a username and password as I wanted, but the problem is that it doesn't except the user/password that I've created, it just continuously denies and prompts again, as if the username/password combination is wrong.
What is wrong with my setup?

Here is what /var/log/apache2/error.log says:

[Wed Dec 07 18:00:47 2011] [error] [client] File does not exist: /var/www/mydir/favicon.ico
[Wed Dec 07 18:01:07 2011] [error] [client] Digest: user `enedene' in realm `Private' not found: /private

The first line is when I connect to site, but the site works, the second line is when I try to access the /var/www/mydir/private dir, authentication comes to browser but I can't get in.

After changing AuthName to "users" new error:

[Wed Dec 07 18:07:59 2011] [error] [client] access to /private failed, reason: require directives present and no Authoritative handler.

I believe since your realm is users then your AuthName directive should be "users"

Instead of AuthNmae "Private" try, AuthName "users" restart apache with;

sudo service apache2 reload

  • 1
    It seems that you're right, but now I have a new error. Look at EDIT 2. – enedene Dec 7 '11 at 17:11
  • 1
    Instead of Require enedene; try, Require valid-user – Sabacon Dec 7 '11 at 17:25

After AuthUserFile, add this:

AuthGroupFile /dev/null

Does this help after restarting Apache? If not, what does ${APACHE_LOG_DIR}/error.log have to say when authentication fails?

  • See the post EDIT. The error stays. – enedene Dec 7 '11 at 17:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.