Configure protected directories in Apache Kodekloud

 


Question:

Solution :

Login to server

ssh [email protected]  

Add a user and set password

sudo htpasswd -c /etc/httpd/.htpasswd james

Restart

sudo systemctl restart httpd

Edit configuration

sudo vi /etc/httpd/conf/httpd.conf 

Scroll down to the <Directory> section for "/var/www/html" and change  

AllowOverride to All

Create mentioned Directory

mkdir /var/www/html/sysops 

Go to sysops directory and create .htaccess file

sudo vi .htaccess

Give this configuration

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

Now go to jump server and copy index file

 scp /tmp/index.html [email protected]:/tmp

Again copy from tmp folder to mentioned directory

cp /tmp/index.html /var/www/html/sysops

Check by typing this curl command

curl -u james http://127.0.0.1:8080/sysops/index.html




Share on Google Plus

About Ashadullah Shawon

I am Ashadullah Shawon. I am a Software Engineer. I studied Computer Science and Engineering (CSE) at RUET. I Like To Share Knowledge. Learn More: Click Here
    Blogger Comment
    Facebook Comment

2 comments:

  1. the task is to check curl -u james http://127.0.0.1:8080/sysops..not
    curl -u james http://127.0.0.1:8080/sysops/index.html. u will get error 301 permanent move..

    ReplyDelete
  2. That is right, rest of the steps work.
    curl -u james:[password] http://127.0.0.1:8080/sysops/index.html


    ReplyDelete