How to access protect folder by apache HTTP Basic Authentication using cURL

Normally if you try to access protect folder by Basic Authentication without proper credentials you will get 401 Unauthorized error:

Example:

curl -s https://yourwebserver.com/mysecure

<!DOCTYPE HTML PUBLIC “-//IETF//DTD HTML 2.0//EN”>
<html><head>
<title>401 Unauthorized</title>
</head><body>
<h1>Unauthorized</h1>
<p>This server could not verify that you
are authorized to access the document
requested.

Read the rest

How to protect a web folder using HTTP Basic Authentication with Apache2

Run the following to create a password file and enter your password

htpasswd -c /etc/httpd/passwd/myverysecrepasswords admin

-c flag means create a new file

Edit the following accordingly your needs and append into your httpd.conf file

<Directory "/var/www/html/mysecure">
AuthType Basic
AuthName "Protected Files"
AuthBasicProvider file
AuthUserFile /etc/httpd/passwd/myverysecrepasswords
Require user admin
</Directory>

 

Common paths where httpd.confRead the rest