⭐️How to Configure Basic Authentication in the Apache WebServer⭐️
So In this article, we discussed how we can create authentication in our Apache webserver.
for that first start with what is authentication or website authentication and what is basic authentication and why we need this?
Authentication is the security process that allows users to verify their identities in order to gain access to their personal accounts on a website. or Authentication is any process by which you verify that someone is who they claim they are.
📝Basic Authentication 🔐
Basic authentication is a simple authentication scheme built into the HTTP protocol. The client sends HTTP requests with the
Authorizationheader that contains the word
Basicword followed by a space and a base64-encoded string
username:password. For example, to authorize as
demo / p@55w0rdthe client would send.
So why we need this?
if you have information on your web site that is sensitive or intended for only a small group of people, the techniques in this article will help you make sure that the people that see those pages are the people that you wanted to see them.
Apache HTTP Server is a free and open-source web server that delivers web content through the internet. It is commonly referred to as Apache and after development, it quickly became the most popular HTTP client on the web.
For this Configuration I use two ways:
- Using Ansible Playbook.
Here are Some Steps to httpd Authentication Showing in the below figure:
Step 1: Install Package
So, start with manually configure basic authentication in your web server go to the terminal, and check httpd package is install or not if they don't install using this below command we can install it.
Installation Command of Httpd
# yum install httpdcheck Httpd install or not
# rpm -q httpd
Step 2: Go to this folder :
var/www/html and create one html page
# cd /var/www/html
# vi index.html
Step 3: Configure Httpd and go to the file cd /etc/httpd/conf
and search file named as httpd.conf and then replace none keyword to AuthConfig in this file.
Step 4: Create .htaccess file in the document root of the httpd.
In short go to var/www/html and create one file named as .htaccess
starts with .name of the file is hidden files in our system. for check file is available or not use below command:
# ls -a
Now in the file, we can write basic authentication
Now the important step for authentication is to create user name and password.
Step5: Create user name and Password for this we can use below command:
# htpasswd -c /etc/www.passwd username
start the httpd service using the below command:
# systemctl start httpd
Now test basic authentication start or not in our webserver go to browser and check:
So now I am using an ansible tool for doing this basic autitentication and create a playbook, using ansible-playbook this manual process is more optimize and fast.
Now performing all the steps and write the script in the playbook, In this Playbook, we have also installed passlib library:
I hope you like this article!!!!!!
Keep Learning 🤩