Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save AbdullahGhani1/31bd7ea4f763e300a7c2361eceb08132 to your computer and use it in GitHub Desktop.
Save AbdullahGhani1/31bd7ea4f763e300a7c2361eceb08132 to your computer and use it in GitHub Desktop.
Configure protected directories in Apache - KodeKloud

Configure protected directories in Apache

xFusionCorp Industries has hosted several static websites on Nautilus Application Servers in Stratos DC. There are some confidential directories on document root that need to be password protected. Because they are using Apache for hosting the websites, the production support team has decided to use .htaccess with basic auth. There is a website that needs to be uploaded to /var/www/html/dba on Nautilus App Server 2. However, we need to set up the authentication before that. Create /var/www/html/dba directory if doesn't exist. Add a user mariyam in htpasswd and set its password to BruCStnMT5. There is a file /tmp/index.html placed on Jump Server. Copy the same to new directory you created, please make sure default document root should remain /var/www/html. Also website should work on URL http://app-server-hostname:port/dba

Click on ✔ and Do Task Again

Solution:-

ssh on a app server According to Task
ssh steve@stapp02

Add user name According To Task.

sudo htpasswd -c /etc/httpd/.htpasswd mariyam
sudo systemctl restart httpd && sudo vi /etc/httpd/conf/httpd.conf

Search and Config According to Image

Image

sudo mkdir /var/www/html/dba && sudo cd /var/www/html/dba
sudo vi .htaccess

Add Below Lines into File

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

Open New Terminal : On Jump Server

scp /tmp/index.html tony@stapp01:/tmp

on stapp01 "According to task"

sudo cp /tmp/index.html /var/www/htm/dba
curl -u mark  http://127.0.0.1:8080/dba/index.html  
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment