Red Antigua Logo
Yet another piece of web.
Search this site (by Google)
Tools    (top)
Check a site for broken links
(W3C)

Perl modules    (top)
Tree::Numbered::Tools
(CPAN)
Perl tutorials    (top)
Perl modules
HTML::Template
CGI::Application
Cookies with CGI::Application
Upload files with CGI::Application
Download files with CGI::Application
Redirect with CGI::Application
CPAN shell
Install DBD::mysql from the CPAN shell
Perl trim function
Validate an IP with Perl
Run suid Perl scripts under Apache
Perl taint mode
Perl date functions with Date::Calc

In Spanish
Curso de Perl

C tutorials    (top)
C - Introduction
C - Absolute beginner's Emacs
C - Examples for beginners
C - Makefile examples
C - Autotools examples
Server configurations    (top)
DNS
Apache
Apache Authentication and Access Control
mod_perl on FreeBSD
MySQL
MySQL add account
phpMyAdmin
Squid
DHCP

UNIX on Windows    (top)
MSYS2 - UNIX environment for MS Windows 32/64 bits
Apache setup on Windows
MySQL setup on Windows
PHP setup on Windows
Perl setup on Windows
Emacs setup on Windows
PuTTY
WinSCP
GIMP on Windows
MinGW - gcc on Windows
MSYS - UNIX-styled shell on Windows
msysDTK - autotools on Windows
GDB for MinGW on Windows

Misc. FreeBSD/UNIX    (top)
'portupgrade' on FreeBSD
'ipf' on FreeBSD
'pf' on FreeBSD
'su' on FreeBSD
Mount an ISO image under FreeBSD
Load the correct sound driver under FreeBSD without knowing what sound card you are using
Simultaneous sound channels on FreeBSD
FreeBSD network stuff
DOS-to-UNIX file conversion
favicon.ico on UNIX
Emacs tips
Command Line Calculator
Save multimedia streams with 'mplayer'
xargs - solution to 'Argument list too long'
Process multiple images from the command line using 'ImageMagick'
Turn the system bell off under X Windows
Process each line in an input file from the command line (or in a shell script)
How to keep a program running in the background using 'nohup'
How to remove symbolic links in the current directory using 'find' and 'rm'
How to remove Emacs backup files in the current directory and all subdirectories using 'find' and 'rm'
How to execute .profile without logging in
Configure X to handle non-English characters
How to move /var to /usr/var

Redirect a web page    (top)
Redirect to another web page
Apache redirect
C redirect
Perl redirect
PHP redirect
HTML redirect
JavaScript redirect

Javascript    (top)
Trim function
Login form
Register form
Popup window

Apache Authentication and Access Control
Apache Authentication and Access Control
This tutorial describes how to protect a directory in Apache with a password, and control access by client IP.
We assume that Apache is installed in
/usr/local/apache
and that you have write access to
/usr/local/apache/conf/httpd.conf.
We will not take use of .htaccess files.
The advantage of not using a .htaccess file is described here:
Apache 1.3:
http://httpd.apache.org/docs/1.3/howto/htaccess.html#when
Apache 2.2:
http://httpd.apache.org/docs/2.2/howto/htaccess.html#when
(It is also more tricky to manage file permissions on .htaccess files, especially if you run Apache with SuEXEC and use different system users for each Virtual Host.)

Create a password file
/usr/local/apache/bin/htpasswd -c /usr/local/apache/conf/htpasswd someuser
New password:
Re-type new password:
Edit httpd.conf
In this example we will protect /usr/local/apache/htdocs, but you can choose any directory, of course.
We will use Basic autentication, and password will be required from anywhere except from localhost (127.0.0.1).
<Directory "/usr/local/apache/htdocs">
  AuthType Basic
  AuthName "Your title for the popup window"
  AuthUserFile /usr/local/apache/conf/htpasswd
  Require valid-user	
  Order allow,deny
  Allow from 127.0.0.1
  Satisfy any
</Directory>
Restart Apache
/usr/local/apache/bin/apachectl stop
/usr/local/apache/bin/apachectl start (or startssl)
Test the configuration
Point your browser to the protected directory, both from the same server (should not ask for password) and from another box (should ask for password).

Read more
Apache 1.3:
http://httpd.apache.org/docs/1.3/howto/auth.html
Apache 2.2:
http://httpd.apache.org/docs/2.2/howto/auth.html

Last modified: Fri Aug 24 10:15:19 Romance Daylight Time 2007