Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Apache-Password Protect Directory and Force SSL
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
Shiner_Man
Apprentice
Apprentice


Joined: 09 Mar 2004
Posts: 180

PostPosted: Thu Jul 01, 2004 8:01 pm    Post subject: Apache-Password Protect Directory and Force SSL Reply with quote

I just installed Acid with mysql and snort but I don't want everybody having access to the alert statistics. What I want to do is password protect the acid main page and force it to use ssl.

I read some of th documentation on apache's site but I find it very confusing. Is their an easy way to set this up?
_________________
My Site
Back to top
View user's profile Send private message
Shiner_Man
Apprentice
Apprentice


Joined: 09 Mar 2004
Posts: 180

PostPosted: Thu Jul 01, 2004 11:25 pm    Post subject: Reply with quote

Okay after messing around with a bunch of things I figured out how to password protect the directory. Here is what I did.


Code:
# cd /var/www/localhost/htdocs/acid
# htpasswd2 -c .htpasswd aciduser


This will create the .htpasswd file and add the user aciduser with a password. Then I created the .htaccess file in the same directory which looks like this:

Code:
AuthUserFile /var/www/localhost/htdocs/acid/.htpasswd
AuthGroupFile /dev/null
AuthName "ACID Server"
AuthType Basic

require user aciduser


Then I had to add the following to /etc/apache2/conf/commonapache2.conf:
Code:

<Directory /var/www/localhost/htdocs/acid/>
AllowOverride All
</Directory>


Restart apache:

Code:
/etc/init.d/apache2 restart


and everything works fine.

Two questions. Should the .htaccess and .htpasswd files be saved somewhere else? How can I force this page to only work through ssl?
_________________
My Site
Back to top
View user's profile Send private message
MrSpock
n00b
n00b


Joined: 13 Jan 2003
Posts: 43

PostPosted: Fri Jul 02, 2004 9:11 am    Post subject: Reply with quote

The .htpasswd file shouldn't stay in your web-root, as it may be readable through browser. The .htaccess has to stay exactly in the directory you wonna protect. Make sure the rule for denying read access through apache to that file is denied. (should be if you didn't delete that section)
_________________
If we could change our past,
would that also change who we are?
Back to top
View user's profile Send private message
Shiner_Man
Apprentice
Apprentice


Joined: 09 Mar 2004
Posts: 180

PostPosted: Fri Jul 02, 2004 7:07 pm    Post subject: Reply with quote

So where is the recommended place to put .htpasswd? In /etc somewhere?
_________________
My Site
Back to top
View user's profile Send private message
MrSpock
n00b
n00b


Joined: 13 Jan 2003
Posts: 43

PostPosted: Fri Jul 02, 2004 7:09 pm    Post subject: Reply with quote

i put it in the root dir of my homedir.
_________________
If we could change our past,
would that also change who we are?
Back to top
View user's profile Send private message
Shiner_Man
Apprentice
Apprentice


Joined: 09 Mar 2004
Posts: 180

PostPosted: Sat Jul 03, 2004 2:06 am    Post subject: Reply with quote

Okay. I'd rather put it somewhere else like /etc/apache2 since I clean out my home directory often.
_________________
My Site
Back to top
View user's profile Send private message
hanj
Veteran
Veteran


Joined: 19 Aug 2003
Posts: 1500

PostPosted: Sat Jul 03, 2004 5:39 am    Post subject: Reply with quote

Assuming you have SSL configured and working on the server, this is how you'd force SSL for that request

In you /etc/apache2/conf/vhosts/vhosts.conf file you'll need to add a entry for acid:

Code:

<Directory "/var/www/localhost/htdocs/acid">
RewriteEngine on
RewriteBase /acid/
RewriteCond %{SERVER_PORT} ^80$
RewriteRule ^(.*) https://www.yourdomain.com/acid/ [R]
</Directory>


You could optionally add your .htaccess directive within apache confs too... in /etc/apache2/conf/ssl/vhost/vhosts.conf

Add this:
Code:

<Directory "/var/www/localhost/htdocs/acid">
# normal SSL stuff here..once again assuming you have it working

# additional directives
AllowOverride None
Options Includes -FollowSymLinks IncludesNoExec

# add auth stuff here
AuthUserFile /somewhere/not/under/webroot/.htpasswd
AuthGroupFile /dev/null
AuthName "ACID Server"
AuthType Basic
<Limit GET>
require user aciduser
</Limit>
</Directory>


I hope this helps
hanj
Back to top
View user's profile Send private message
BlinkEye
Veteran
Veteran


Joined: 21 Oct 2003
Posts: 1046
Location: Gentoo Forums

PostPosted: Sat Oct 23, 2004 9:35 am    Post subject: Reply with quote

i'm looking for a similar solution since a long time. still, it doesn't work for me. what i want is access a users directory with a login. but i want to be redirected to the secure socket before authenticating, how do i do that?

example: http://foodomain/~myuser -> rewrite to: https://foodomain/~myuser and NOW ask me to authenticate. any idea?
_________________
Easily backup up your system? klick
Get rid of SSH Brute Force Attempts / Script Kiddies klick
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum