★ wanayoo — archive 1999 http://www.linuxplanet.com/linuxplanet/tutorials/1527/5/Nouvelle recherche | Portail wanayoo
Home | Windows | Linux | Hardware | Shopping | Web Building | Downloads |Tech Support
LinuxPlanet
Search 
  Power Search | Tips 

 Front Door
 Discussion
 LinuxEngine
 Opinions
 Reports
 Reviews
 Tutorials

 Tech Support »


 Browse by subject.
Grow your revenue stream!
Internet Advertising Report
internet.com
Internet News
Internet Stocks/VC
Internet Technology
Windows Internet Tech.
Linux/Open Source
Web Developer
ECommerce/Marketing
ISP Resources
ASP Resources
Downloads
Internet Resources
Internet Lists
International

Search internet.com
Advertising Info
Corporate Info
Print this article
Email this article

  LinuxPlanet / Tutorials



www.searchenginewatch.com

Security and Apache: An Essential Primer
Restricting by IP Address

Ken Coar

Since the IP address is one of those aspects of a client-server HTTP relationship that cannot be changed mid-stream, and cannot be easily faked (without the cooperation of the intervening network systems), it's considered a nondiscretionary control. The Apache distribution includes a module for limiting access thusly, called mod_access.

The mod_access module allows you to specify what domains or addresses should or should not be allowed access, and in which order the two lists (allowed and denied) should be evaluated. The basic syntax of the Allow and Deny directives is:

    Allow from host-or-network

The host-or-network can be:

  • a host or domain name (www.foo.com),
  • an IP address (10.0.72.3),
  • an IP address and subnet mask (10.0.0.0/255.0.0.0), or
  • an IP address and CIDR mask size (10.73.128.0/18)

Whenever possible you should use IP addresses instead of domain names; using names means that the Apache server needs to do a double-reverse lookup on them to make the translation to the IP address of the client. (A double-reverse lookup, which is always done by Apache when dealing with host names in security-related situations, involves translating the name to an IP address, and then translating that IP address back to a list of names. If the translations don't work in both directions, Apache will consider the host/domain name match to have failed.)

As an added fillip, an alternate form of the Allow and Deny directives, "from env=[!]envariable-name", allows you to make the go/no-go decision based upon the presence (or absence) of an environment variable. The envariable may have been set for the entire server environment, or it may have been set just for the current request by a module such as mod_setenvif.

The Order directive controls how the cumulative lists of Allow and Deny directives are interpreted. If the order is Allow,Deny (note that no spaces are permitted between the keywords!), then the initial state is the equivalent of Deny from All, the Allow conditions are processed, and then the Deny list is. For Order Deny,Allow, the opposite is the case--the initial state is "allow everyone," then denials are handled, and then the allows are used to override them.

The easy way to remember the default state is to recall that it matches the last keyword: Deny,Allow means "allowed," and Allow,Deny means "denied."

There is a third possibility for the Order directive: mutual-failure. With this keyword, there is no "default state"--the only clients that will be allowed in are those that don't appear on any Deny directive, but do appear on at least one Allow directive.

Restricting by User Credentials
If you want to protect pages such that visitors need to enter a username and password, the mod_auth module is your tool. It is one of the simplest and easiest to use of the discretionary control modules.

The key directives in establishing access controls are those that define the location of the credential database and identify the authorized users. For mod_auth, the directives in question are AuthUserFile and Require. Other modules have similar directives.

The AuthUserFile directive simply takes a fully specified filename path (such as /home/foo/.htpasswd-foo), which tells the module where to find the text authentication file for the module to use in the current realm. No path-shortening or relative file specifications are permitted.

The Require directive is actually part of the core server rather than being specific to mod_auth, so it's documented (however sparsely) at <http://www.apache.org/docs/mod/core.html#require>. Require is covered in more detail shortly.

Next: Labelling and Inheritance »

Skip Ahead

1 Maxwell's Demon and Hat Colour
2 Mandatory Versus Discretionary Access Control
3 Realms: Areas of Controlled Access
4 Apache Security Processing Phases
5 Restricting by IP Address
6 Labelling and Inheritance
7 The Standard Apache Security Modules
8 Which Database is Authoritative?
9 Conclusions/For More Information

Internet Advertising Report

internet.com home | write us | search | help! | about us

 Copyright © 1999-2000 internet.com Corporation. All Rights Reserved.
About internet.com Corp. | Press Releases
Privacy Policy | Career Opportunities