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/sysops on Nautilus App Server 1. However, we need to set up the authentication before that.
1. Create /var/www/html/sysops direcotry if doesn't exist.
2. Add a user mark in htpasswd and set its password to ksH85UJjhb.
3. 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>/sysops
Sample Answer:
# login to the given server in the question
ssh <user>@<server>
#switch to root user
sudo su
#create /var/www/html/sysops directory (check your question)
mkdir /var/www/html/sysops
#Add a user and set password ( check your question username and password)
htpasswd -c /etc/httpd/.htpasswd mark
* above command will ask for a new password for the user, paste the password given in question
#Go to sysops directory and create .htaccess file
vi .htaccess
#paste below configurationlines
AuthType Basic
AuthName "Password Required"
Require valid-user
AuthUserFile /etc/httpd/.htpasswd
#copy the index file from jump server
scp /tmp/index.html <user>@<server>:/tmp
#now from the your app server copy the file to the correct location
cp /tmp/index.html /var/www/html/sysops/
# verification ( you need to submit the newly created user and user's password to access the file )
curl -u mark http://<appserver IP>:8080/sysops/
*Please comment on this post if you facing any issues in the steps, also provide your feedback in the comments :)
Note: **The Question copied it for learning purposes.** Commands are correct but based on your question the server, user name, and other details might differ, so please do check.
No comments:
Post a Comment