sábado, 17 de octubre de 2015

Basic Authentication in Apache 2.4

Requirements

It’s required to install apache2-utils

sudo apt-get install apache2-utils

Create users

Run the htpasswd command with the -n flag to generate a new user in the standard access file. But we are going to create a file in a different location.

mkdir /etc/htpasswd
htpasswd -c /etc/htpasswd/.htpasswd victor

To add a new user not use -c option

Add protection

Add the next directive inside context directory in you virtual host.

  AuthType Basic
  AuthName "Authentication Required"
  AuthUserFile "/etc/htpasswd/.htpasswd"
  Require valid-user

Note: Must exist only one Require directive. If Require all granted is exist then the user could see the site witout being authenticated.

Written with StackEdit.

No hay comentarios:

Publicar un comentario