Australian cloud for business software — built and run in Sydney since 2002

NetLeverage
NetLeverage

Apache AH01630: client denied by server configuration (403 Forbidden)

Technical article
Troubleshooting

About this article: This article is reviewed against the cited sources. This is source research, not lab validation. Check the stated versions and your own requirements before making changes.

The Apache error log line AH01630: client denied by server configuration: /var/www/example/page.html says that Apache 2.4's authorisation rules (Require) were evaluated for the request and none of them granted access, so Apache answered 403 Forbidden. It is a configuration decision, not a file permission fault. The path after the colon is what to look at: the Directory, Location or Files section that applies to that path decides the outcome, and a missing Require all granted, a rule that only subtracts, or old Apache 2.2 directives mixed in with the new ones are three causes that produce it.

What the error means

In the Apache 2.4.71 source, mod_authz_core logs client denied by server configuration: %s%s with the message number AH01630 when the authorisation result is denied or neutral, and the request needs no authentication. It then returns 403. The path is the resolved file name, or uri followed by the URI when the request has no file (for example a proxied path).

The same words are logged by a second module with a different number. mod_access_compat, which implements the old Order, Allow and Deny directives, logs AH01797: client denied by server configuration. The number tells you which rule family denied the request:

  • AH01630: the new Require rules (mod_authz_core, mod_authz_host).
  • AH01797: the old Order, Allow from and Deny from rules (mod_access_compat).

Other 403 errors have different text, which saves a search in the wrong place: AH00035: access to %s denied (filesystem path '%s') because search permissions are missing on a component of the path is a file system permission problem, AH00036: access to %s failed is another file system failure, and AH00037: Symbolic link not allowed or link target not accessible is an Options FollowSymLinks problem.

How a decision is made

Each Require directive returns Granted, Denied or Neutral. The Apache documentation sets out how containers combine them:

Container Granted if Denied if Neutral is treated as
RequireAny at least one provider grants all providers deny deny
RequireAll no provider denies (and at least one grants) any provider denies grant
RequireNone no provider grants any provider grants grant

Several Require lines that are not inside a container are treated as if they sat inside a RequireAny, so the first one to grant access decides. A negated line, such as Require not ip 203.0.113.0/24, "can only fail or return a neutral result, and therefore may never independently authorize a request". A Directory block holding only Require not ... therefore denies everyone.

The upstream default configuration file sets <Directory /> to Require all denied, then grants access with Require all granted to the document root and to the CGI directory, and denies .ht* files. Its own comment on Alias says: "You will also likely need to provide a <Directory> section to allow access to the filesystem path." A directory outside the document root, reached through Alias, is therefore denied unless it has its own grant.

Sections merge in a fixed order, per the documentation: <Directory> (not regular expressions) and .htaccess together, then <DirectoryMatch>, then <Files> and <FilesMatch>, then <Location> and <LocationMatch>, then <If>. Authorisation in Location sections overrides Directory by default, and the AuthMerging directive (default Off) controls combining.

Likely causes

Cause What you see How to confirm
No Require all granted for the directory, for example one reached by Alias outside the document root AH01630 with a path outside DocumentRoot Directory blocks in the configuration against the logged path
Only negated Require not lines Everyone denied, even addresses not listed Look for a block with no positive Require
Old Order/Allow/Deny mixed with Require AH01797, or a 403 that the new rules seem to allow Both rule families in the same section. The upgrading guide documents this
A Location section overriding a Directory rule A path is open or closed unexpectedly The merge order above, and AuthMerging
Require ip or Require host list does not include the real client 403 only for some clients Client address in the log against the list. Behind a load balancer the address Apache sees may be the proxy's
A module the rules depend on is not loaded Depends on the module. Old rules need mod_access_compat httpd -M for access_compat_module, authz_core_module, authz_host_module

Prove the cause before changing anything

1. Read the log line. Record the message number (AH01630 or AH01797), the path, and the client address in the same entry. The documentation's example ErrorLogFormat shows these pieces: time, level, process, client address and message.

2. List the loaded modules and virtual hosts.

httpd -M
httpd -S

-M dumps the loaded static and shared modules, and -S shows the settings as parsed, currently the virtual hosts. Check that the vhost you expect is the one answering.

3. Find every rule that can apply to the path. Search the whole configuration tree for Require, Order, Allow from, Deny from, AuthMerging and AllowOverride. If AllowOverride permits it, also read the .htaccess files on the path. Write down the sections in merge order, using the order above.

4. Ask Apache for its decision. Per-module log levels exist in 2.4: LogLevel takes [module:]level, for example LogLevel info ssl:warn in the documentation. mod_authz_core logs authorization result of %s: %s at debug level (message AH01626) for each Require it evaluates, so LogLevel warn authz_core:debug shows which line returned what.

Disruptive step: this needs a configuration change and a reload. Save a copy of the file, run httpd -t (or apachectl configtest), then reload with apachectl -k graceful (or do a full restart). The debug level adds log volume. To back out, remove the line and reload.

5. Test from a known address.

curl -si http://app.example.com/files/report.pdf

-s silences progress output and -i shows the response headers, so you can see 403 and the Server header.

Fix

Disruptive step: every Require edit below changes who can reach the live site. Keep a copy of each file, run httpd -t first, apply with a graceful reload, and restore the copy if the change opens more than intended.

Grant access where it is intended

<Directory "/srv/files">
    Require all granted
</Directory>

Require all granted is documented as "Access is allowed unconditionally." Use Require ip 192.0.2.0/24, Require host example.org or Require local for restricted areas. The documentation describes Require ip as accepting forms such as 10.1.0.0/16.

Combine allow and deny correctly

<RequireAll>
    Require all granted
    Require not ip 203.0.113.0/24
</RequireAll>

A negated line needs a positive one beside it, inside a RequireAll, to have any effect.

Risk: this edit decides which clients are blocked. A wrong Require not line can lock out a valid network or leave a blocked one in. To back out, restore the previous block and reload gracefully.

Move wholly to the new rules

The upgrading guide maps old to new: Order deny,allow with Deny from all becomes Require all denied; Order allow,deny with Allow from all becomes Require all granted; Order Deny,Allow, Deny from all, Allow from example.org becomes Require host example.org. It says mixing old and new "is technically possible but discouraged", and shows a case that "leads to unexpected results": an old Order deny,allow / Deny from all in a Directory plus Require local in a Location still logs AH01797, "because mod_access_compat directives take precedence over the mod_authz_host one in this configuration merge scenario". Migrate everything in one change.

Risk: converting rule families rewrites the access rules for every section you touch, and a half-converted file can open or close paths unexpectedly. To back out, restore the saved configuration and reload gracefully.

Location against Directory

The documentation's own warning: "Regardless of any access restrictions placed in <Directory> sections, the <Location> section will be evaluated last and will allow unrestricted access to the server." Its example, a Location "/" with Require all granted followed by a Directory "/" restriction, carries the code comment # Whoops! This <Directory> section will have no effect. If a path is served from the file system, put the access rule in Directory, or set AuthMerging deliberately.

Disruptive step: after editing, run httpd -t (or apachectl configtest) and then apachectl -k graceful. The -t option "immediately exits after these syntax parsing tests". To back out, restore the previous file and reload.

Example (illustrative): web01 serves app.example.com from /var/www/app and has an Alias /files /srv/files. A new report folder under /srv/files returns 403. The error log shows AH01630: client denied by server configuration: /srv/files/report.pdf. No Directory block covers /srv/files, and the base configuration sets <Directory /> to Require all denied. Adding the Directory "/srv/files" block with Require all granted and a graceful reload serves the file. A client address in an allow list would not have helped, because no rule granted anything.

Confirm the fix

  1. The same URL returns 200, with the file's content.
  2. A path outside the intended area still returns 403. The fix should not have exposed the whole server.
  3. If you restricted by address, test from an allowed and a blocked address.
  4. No new AH01630 or AH01797 lines appear for the same path.

What to watch afterwards

  • After any Apache upgrade or a copy of old configuration, search for Order, Allow from and Deny from.
  • Keep access rules in one place for each served area, and note any Location that overrides them.
  • Remove the temporary authz_core:debug level when finished.

Risks and limits

  • These commands have not been run or lab-tested. They are taken from the Apache documentation and the 2.4.71 source listed below.
  • Message wording and numbers are from 2.4.71. Earlier 2.4 releases may differ.
  • A broad Require all granted exposes everything in that directory. Grant the narrowest scope that works.
  • .htaccess files, AllowOverride and distribution-specific include files can add rules that are not in the main configuration file.
  • File permission denials, SELinux and other 403 causes produce different log messages and are not covered beyond the numbers listed.

Sources