Apache: erreur dans le .htaccess

Salut à tous,

Je vous demande vos yeux quelques secondes :open_mouth:
J’ai configuré un fichier de mot de passe dans un répertoire Web (.htaccess).
Mais même en utilisant le bon mot de passe, je ne parviens pas à ouvrir la page web…

Voici la conf du virtualhost:

<VirtualHost *> ServerAdmin webmaster@toto.net DocumentRoot /var/www/cgiproxy.toto.net ServerName cgiproxy.toto.net ErrorLog /var/log/apache2/cgiproxy.toto.net.error.log CustomLog /var/log/apache2/cgiproxy.toto.net.access.log common AddHandler cgi-script .cgi <Directory /var/www/cgiproxy.toto.net> AllowOverride FileInfo AuthConfig Limit Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec #DirectoryIndex nph-protected.cgi AuthUserFile "/var/www/cgiproxy.toto.net/.htpasswd" AuthName "Restricted" AuthType Basic Require valid-user #Order allow,deny #Allow from all Options +ExecCGI </Directory> </VirtualHost> et voici le fichier de mot de passes:root@MALIBU:/var/www/cgiproxy.toto.net# pwd /var/www/cgiproxy.toto.net root@MALIBU:/var/www/cgiproxy.toto.net# cat .htpasswd toto:foobar root@MALIBU:/var/www/cgiproxy.toto.net#Je vais sur la page cgiproxy.toto.net/nph-proxy.cgi, j’ai la pop-up d’identification qui appraît.
Je tape toto comme login et foobar en mot de passe, et il me redemande encore…

Une idée ?
Merci

[code]# htpasswd -c /var/www/cgiproxy.toto.net/.htpasswd toto
New password: <-- foobar
Re-type new password: <-- foobar
Adding password for user toto

cat /var/www/cgiproxy.toto.net/.htpasswd

toto:2O29gg/V1ySf6[/code]

Ben…

root@MALIBU:/var/www/cgiproxy.toto.net# htpasswd -c .htaccess edern New password: Re-type new password: Adding password for user edern root@MALIBU:~# /etc/init.d/apache2 restart root@MALIBU:~# tail /var/log/apache2/cgiproxy.toto.net.error.log [Tue Nov 06 20:11:45 2007] [alert] [client 192.168.20.2] /var/www/cgiproxy.toto.net/.htaccess: Invalid command 'edern:Q3hdObo5GqeBU', perhaps misspelled or defined by a module not included in the server configurationetroot@MALIBU:~# dpkg -l | grep apache ii apache2 2.2.6-1 Next generation, scalable, extendable web se ii apache2-mpm-worker 2.2.6-1 High speed threaded model for Apache HTTPD ii apache2-utils 2.2.6-1 utility programs for webservers ii apache2.2-common 2.2.6-1 Next generation, scalable, extendable web se root@MALIBU:~# :question: :question:

tu as mal lu là :stuck_out_tongue:

regardes, tu confonds un peu le fichier htaccess et le htpasswd

Fatigue ? allez courage, tu y es presque. :wink:

J’ai renommé le fichier .htpasswd pour en faire un .htaccess pour être plus “académique” (au cas où ça changerai quelquechose).

Mais non :confused:

Bien c’est pas ça c’est toi qui défini le fichier cf

[quote](au cas où ça changerai quelquechose).
Mais non :confused:[/quote]

Vérifier tes fichiers l’erreur à rien de logique ton alerte de “commande” dans un fichier de données…

http://www.toulouse-renaissance.net/c_outils/c_htaccess_htpasswd.htm

Salut,
une petite recherche sur google :
infres.enst.fr/~danzart/frames/htaccess.html

Supprime ces lignes de ton virtualhost, car elle doivent être placée dans un fichier .htaccess:

AuthUserFile "/var/www/cgiproxy.toto.net/.htpasswd" AuthName "Restricted" AuthType Basic Require valid-user #Order allow,deny #Allow from all

c pas ça:

mais ça:

man htpasswd pour les options.

Ensuite tu crée ton fichier .htaccess:

et tu mets ça:

[code]AuthName Protected
AuthUserFile /var/www/ton_site/.htpasswd
AuthGroupFile /dev/null
AuthType Basic

require valid-user [/code]

Bref, au finale tu dois avoir 2 fichiers dans /var/www/ton_site:
.htaccess et .htpasswd

Pour vérifier:

Bonne chance :wink:

Salut,

bon finalement je cherchais un truc simple, j’ai pris le bouquin Apache Security de O’Reilly.
Paragraphe 7.3.1:

[quote]You need to create a password file using the htpasswd utility (in the Apache /bin folder after installation). You can keep it anywhere you want but ensure it is out of reach of other system users. I tend to keep the password file at the same place where I keep the Apache configuration so it is easier to find:

htpasswd -c /usr/local/apache/conf/auth.users ivanr

New password: ******
Re-type new password: ******
Adding password for user ivanr

This utility expects a path to a password file as its first parameter and the username as its second. The first invocation requires the -c switch, which instructs the utility to create a new password file if it does not exist. A look into the newly created file reveals a very simple structure:

# cat /usr/local/apache/conf/auth.users ivanr:EbsMlzzsDXiFg

To password-protect a folder, add the following to your Apache configuration, replacing the folder, realm, and user file specifications with values relevant for your situation:

<Directory /var/www/htdocs/review/> # Choose authentication protocol AuthType Basic # Define the security realm AuthName "Book Review" # Location of the user password file AuthUserFile /usr/local/apache/conf/auth.users # Valid users can access this folder and no one else Require valid-user </Directory>[/quote] J’ai fait comme ça, y a tout qui marche !
Merci à tous en tous cas

Content pour toi que ça marche, mais je voulais souligner un truc, c’est que dans ta configue apache globale il y a ceci:

et ceci

<Files ~ "^\.ht"> Order allow,deny Deny from all Satisfy All </Files>

ça veut dire que si tu met autre chose comme nom de fichier pour l’authentification (auth.users) il ne sera pas protégé via ses directive.
Sinon il faut aussi changer ça.

Ta configue quelque part n’a pas de sens, tu active le AllowOverride AuthConfig et tu ajoute l’authentification par mot de passe au niveau de ton vhost !!!
Si tu ajoutes l’auth… au niveau de ton vhost il est inutile d’ajouter la directive AllowOverride AuthConfig, a moins que tu veuilles par la suite ajouter plusieurs htaccess dans tes dossiers…

@ bientôt