Showing posts with label Security. Show all posts
Showing posts with label Security. Show all posts

Wednesday, December 4, 2019

Restricted Access to the website with http basic authentication for additional security layer

Restricted Access to the website with http basic authentication for additional security layer

##############
#For Nginx Server
##############
#Restricted Acccess to the website
#Creating login Username and Password
#SSH access to site folder or root and follow below command line

to create first user >> sudo htpasswd -c /etc/apache2/.htpasswd user1
to create more user >> sudo htpasswd /etc/apache2/.htpasswd user2

Then,

#Add the following code in Nginx server block

    auth_basic              "Restricted Area";
    auth_basic_user_file    /etc/apache2/.htpasswd;

#End - Restricted Access to view the website

check nginx block >> sudo nginx -t
restart nginx >> sudo systemctl nginx restart


###############
#For Apache Server
###############

#Creating login Username and Password
#SSH access to site folder and follow below command line

[sitefolder]:public_html$ sudo htpasswd -c .htpasswd name-of-user
New password:
Re-type new password:
Adding password for user name-of-user
[sitefolder]:public_html$

#End creating User and Password


Then,


#Add in the following code in .htaccess for Restricted Access
AuthName "Restricted Area"
AuthType Basic
AuthUserFile /public_html/.htpasswd
require user dbadmin
#End Restricted Access

Restricted Access to the website with http basic authentication for additional security layer

Restricted Access to the website with http basic authentication for additional security layer ############## #For Nginx Server #########...