Tuesday, October 26, 2010

Password Protection for entire Website with Apache

Just a little note, because this one is often used for a quick (and dirty) password protection of a Website served with an Apache frontend:

1. Create a password file with htpasswd (or httpasswd2):
htpasswd2 -c -m /etc/apache2/apache-passwds your_login_name

2. Extend your Apache config with something like this:
  <LocationMatch "/.*">
        AuthType Basic
        AuthName "Password required"
        AuthUserFile /etc/apache2/apache-passwds
        Require valid-user