0 votes
1 view
in Devops and Agile by (28.1k points)

I created a user with the password but once I go to my index.html page, it doesn't ask for user credentials. Refer to the attachment. Please help.

1 Answer

0 votes
by (48k points)
edited by

Follow the below steps to replicate the correct configs:

sudo htpasswd -c /etc/apache2/.htpasswd <user-name>

Enter Password and confirm

sudo nano /etc/apache2/sites-enabled/000-default.conf

Add the following text:

<Directory "/var/www/html">
AuthType Basic
AuthName "Restricted Content"
AuthUserFile /etc/apache2/.htpasswd
Require valid-user
</Directory>

This should be inside VirtualHost tag

sudo service apache2 restart

sudo nano /etc/apache2/apache2.conf

Change the highlighted entry to all in the doc

<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>

​sudo nano /var/www/html/.htaccess

enter the following content:

AuthType Basic
AuthName "Restricted Content"
AuthUserFile /etc/apache2/.htpasswd
Require valid-user

sudo service apache2 restart

For more information, check out this apache spark.

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...