LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 07-02-2009, 11:31 AM   #1
rogerdv
Member
 
Registered: Jul 2005
Location: Cuba
Distribution: redhat
Posts: 52

Rep: Reputation: 15
protecting directories in apache


Im trying to protect a directory in my web server with password, or by allowing a few internal IPs. the problem is that even when I follow the tutorials, it doesnt works.
Im using virtual host and I add in the VH config this:

Code:
<Directory "/var/www/gh/administrator">
AuthType basic
AuthName "prompt"
AuthUserFile .htpass
Require valid-user
</Directory>
But it keeps asking for the password again and again. I have tried also adding
Code:
AuthGroupFile /etc/apache2/group
Require group MEMBERS
</Directory>
but it is the same

If I try to deny external IPs with this:

Code:
<Directory "/var/www/gh/administrator">
Allow from 192.168.1.7
Order deny, allow
Deny form all
</Directory>
Simply forbids all IPS. Any idea about how to deal with this?
 
Old 07-02-2009, 12:16 PM   #2
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
You need a "AllowOverride AuthConfig" inside the <Directory "/var/www/gh/administrator"> definition.
Also make sure that the password file .htpass is in the above mentioned directory.
Note that's not a good idea to have your password file in a directory accessible via the web server.

Regards
 
Old 07-02-2009, 02:02 PM   #3
rogerdv
Member
 
Registered: Jul 2005
Location: Cuba
Distribution: redhat
Posts: 52

Original Poster
Rep: Reputation: 15
The same, it keep asking the password.
 
Old 07-02-2009, 02:13 PM   #4
dezza
Member
 
Registered: Nov 2004
Location: Denmark
Distribution: ArchLinux, Debian, Gentoo, Ubuntu, VoidLinux
Posts: 133

Rep: Reputation: 18
Thumbs up

Yes and what about the htpasswd file?

You have to create it ..

PHP:
Code:
 <?php echo crypt("password", base64_encode("password")); ?>
Or:
http://www.htaccesstools.com/htpasswd-generator/
http://www.htaccesstools.com/htaccess-authentication/

I cannot remember the shell version of echo'ing htpasswd files, but I've seen it in several tutorials.

Please add it if you have it somewhere.
 
Old 07-02-2009, 04:27 PM   #5
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
The password file can be created using htpasswd. Just make sure it's readable by the user that runs apache.
You can check the apache error_log to see if you find any hints, why it keeps asking for the password.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
protecting home directories munkie_poo Linux - Security 3 07-04-2005 04:55 AM
Password protecting directories in apache niverson Linux - Security 6 03-02-2004 10:40 PM
Password Protecting Folders with Apache wyndman Linux - Newbie 0 06-27-2003 01:11 PM
password protecting two files to two different databases on Apache? RKris Linux - Software 0 02-24-2003 06:04 AM
password protecting directories jayakrishnan Linux - General 2 02-10-2003 05:49 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 04:58 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration