Saturday, June 9, 2012

How to apply Apache(HTTP) authentication on any Domain

HTTP authentication is a process of applying authentication to our Domain so that only authorized people can access it.

The following command is used to create the password file in the doc root which is used to store the passwords of the users to whom you want to give the access.

/usr/local/apache/bin/htpasswd -c /var/www/ username  
htpasswd -c /var/www/ username

  • Use  /usr/local/apache/bin/htpasswd if you are using a Apache with source installation so that it can locate the htpasswd command to create the password file.
  • htpasswd can be directly used if you have done default installation by using tools like yum, rpm etc.
  • -c is used to create the passwd file in the doc root.
  • If you want to add a new user to current file don't use -c as it will create the new file, use the same command without -c and new user name.
  • /var/www/ is the destination of the file where you want to create the password file and passwd is the file name created to store the password.
  • passwd is the standard password file naming used to store the passwords it can vary according to your need.
  • username is the name of the user to whom you want to give access.

 Create the file name .htaccess in doc root of the domain to whom you want to give authentication.

#vi .htaccess

Add the following lines to the .htaccess

AuthType Basic
AuthName "Restricted Files"
AuthUserFile /var/www/
Require valid-user

  • AuthType Basic -- Its used to request password in encrypted format.
  • AuthName "Restricted Files" -- Its used to display the message on the login form, as in this case " Restricted Files" will be showed  on the form.
  • AuthUserFile /var/www/ -- path where the password file is located.
  • Require valid-user -- its implies only users registered are allowed to get the access.

There are few alternative methods also to set the users having access.

  • Require user abc -- It can be used to give access to one user only name as abc.
  • Require group grp1 -- It can be used to define any group to whom you want to give the access.
  • Add the AuthGroupFile /var/www/
  • In that file mention as groups add the group members to whom you want to give access in plain text file. 
  • For ex: grp1: tom law jack

You can check whether your authentication is working properly or not by curl command as well.

Setup fully configurable EFK Elasticsearch Fluentd Kibana setup in Kubernetes

In the following setup, we will be creating a fully configurable Elasticsearch, Flunetd, Kibana setup better known as EKF setup. There is a...