
01-03-2008, 11:43 AM
|
|
iPhoneaholic
|
|
Join Date: Sep 2007
Device + Firmware: iPhone 3GS, 3G & 2G
Operating System: OSX 10.5.x & Windows XP
Posts: 363
Thanks: 14
Thanked 63 Times in 52 Posts
|
|
|
|
Josh, it's definitely possible, and IMO, a good idea, especially if you're on a public network.
I use lightpd, and while I found a lot of info on doing this with Apache, and had to work pretty hard to figure out how to do it with Lighttpd. I ended up writing instructions for myself only for that, but the general principles involved should help you do it with Apache.
Lighttpd was missing the command htpasswd, so I ended up installing Apache temporarily, just to copy that file. You'll already have it so just:
- SSH in as root from your computer.
- htpasswd -c /usr/local/etc/apache-htpasswd.user [username]
- you'll be prompted for a password, and then to confirm it.
- Now the password file is there.
Now add something like this to the apache.conf file:
auth.backend = "htpasswd"
auth.backend.htpasswd.userfile = "/usr/local/etc/apache-htpasswd.user"
auth.require = ( "/ProtectedDocs/" =>
(
"method" => "basic",
"realm" => "Documents",
"require" => "user=yourusername"
),
"/AnotherDir" =>
(
"method" => "basic",
"realm" => "Documents",
"require" => "user=yourusername"
)
)
Then, of course, you need to restart the server so it will use the new configuration.
The basic elements are:
- Create the password (in a directory not available to the server)
- Add the instructions to your configuration file to use the password, where it is stored, and which directories to protect.
This is working great for me, but I don't claim to have much knowledge about it beyond what I've described. As I say, I pieced it together from the Apache info I found. If you do a search on "Apache" "htpasswd" you should find several step by step instructions.
|
|