Protecting a web site area using Apache httpd basic security is very simple but you have no control over the login alert window displayed by the browser, so when at work we saw that since version 2.3 Apache added a module that will let you use a an html form instead of the ugly alert we decided to upgrade to latest version and give it a try.
I compiled Apache 2.4.2 on CentOS 6.2 32 bit. I won’t detail here the installation process, if you need help just follow this tutorial.
The following instructions are based on the mod_auth_form documentation page and the few tutorials I found online.
First of all create a test folder in the web server root and put a test page inside it
1 2 3 4 | |
Then create a login page in the webserver root that will be used to authenticate users
1 2 3 4 5 6 7 8 9 10 11 12 | |
Please note that leaving the action empty, after a successfull login the user will be redirected to the previously requested resource.
Now edit Apache main configuration file enabling required modules
1 2 3 4 | |
and then add a Directory directive to protect the folder
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | |
Now add a user to the .htpasswd file and reload the web server configuration before trying to navigate to the protected folder.
1
| |
