Search code examples
apacheamazon-ec2webserver

Password Protect My Website


I have recently created a new Amazon EC2 instance using Amazon Linux AMI. What is the best way to force a user accessing the domain to enter a username/password before allowing access to the site?

I am currently using apache http server, and saw some resources indicating I need to use a .htaccess file, but was looking for a more concise explanation.


Solution

  • If all you are looking for is server-level access control (i.e. no modifications to your application), you can utilize basic authentication. This is implemented at the Apache web-server level and can be controlled on a directory-by-directory basis if desired using .htaccess files.

    Here is a link to the Apache documentation

    http://httpd.apache.org/docs/2.2/howto/auth.html

    Here is a simple example of how to implement

    http://doc.norang.ca/apache-basic-auth.html