Friday, February 10, 2012

Using User Authentication in virtual host (.htpasswd)

# cd /home/myhome

# htpasswd -c .htpasswd user1
# htpasswd .htaccess user2
# cat .htaccess
user1:J7BhPKjbKUJ6I
user2:j8b9aZmd.DGFw
# chmod 644 .htaccess

# vi /etc/httpd/conf/httpd.conf
.
.
.

NameVirtualHost *:443


    DocumentRoot /home/myhome/www
    ServerName hostname.yourdomain.com
    ErrorLog logs/hostname.yourdomain.com-error_log
    CustomLog logs/hostname.yourdomain.com-access_log common

    SSLEngine on
    SSLCertificateFile /etc/pki/tls/certs/your.crt
    SSLCertificateKeyFile /etc/pki/tls/private/your.key

   
        AuthUserFile /home/myhome/.htpasswd
        AuthGroupFile /dev/null
        AuthName "My Private Directory"
        AuthType Basic
       
            require valid-user
       
   


# service httpd restart