First generate your htppasswd file:
#htpasswd -c htpasswd user_name
assume we put the file in
/home/myusename/htpasswd
Second, assume the site you want to protect is called test.mysite.com on port 80
Put the following for your http configuration. In Ubuntu, it will be a file in your /etc/apach2/sites-enable/ directory
setEnvIfNoCase HOST ^test\.mysite\.com\.?(:80)?$ PROTECTED_HOST
#put this in your location directive
AuthUserFile /home/myusername/htpasswd
AuthType Basic
AuthName "this site is password protected :)"
Order Deny,Allow
Satisfy any
Deny from all
Require valid-user
Allow from env=!PROTECTED_HOST
This configuration, will pop up password for test.mysite.com on port 80.
No comments:
Post a Comment