How to set up HTTP password protection / basic authentication for your Drupal site on AWS server (bitnami image)

| | 1 min read

Some times we need to protect our site from public users and make it available only to selected number of users. For examply you might want to protect your alpha site from the public and from search engine bots. In such situations we protect our site with HTTP password. Follow the below steps for protecting your Drupal site with HTTP password. This was written for an Amazon AWS server but should work on most GNU/Linux servers.

  1. Run the htpasswd utility
    $ sudo /opt/bitnami/apache2/bin/htpasswd -c /opt/bitnami/apache2/httpd-auth username 
    $ cd /opt/bitnami/apps
    $ sudo vi virtualhost
  2. Add the following to virtualhost.conf, between <Directory> and </Directory>
    AuthType Basic
    AuthName yourapplication
    AuthUserFile "/opt/bitnami/apps/httpd-auth" 
    Require valid-user
  3. Restart apache2
    $ sudo /opt/bitnami/ctlscript.sh restart


Now your Drupal site should be protected using basic authentication which should keep it away from spying eyes and all search engine crawlers. It is standard practice to keep your development, staging and testing environments under basic authentication to prevent search engines crawling them and marking them as duplicate content of your main site.