1

I was using the following in my Apache 2.1 installation:

Order allow,deny
Allow from all
Deny from 203.XXX.YYY
Deny from 10.ABC
Deny from 10.CBA
Deny from 10.BCA
Deny from 10.ACB

After updating to 2.4.7; I'm supposed to use the mod_authz_host because of the following

Note

The directives provided by mod_access_compat have been deprecated by the new authz refactoring. Please see mod_authz_host.

I've read the page linked above, and there is no mention of denying certain IP ranges using the Require directive. For now, I've the following in my conf file:

Require all granted

I tried using the following:

Require ip 10.142 denied

But apachectl -t tells me:

AH00526: Syntax error on line 22 of <path_to_apache2>/conf/myown.conf:
ip address 'denied' appears to be invalid

How do I rewrite my former statements in the newer module?

hjpotter92
  • 78,589
  • 36
  • 144
  • 183
  • 1
    The [documentation](https://httpd.apache.org/docs/2.4/howto/auth.html) appears to have several examples showing exactly the syntax you need. – larsks Jan 26 '14 at 13:38

1 Answers1

3

Based on documentation can you replace this line:

Require ip 10.142 denied

By this code:

Require all granted
Require not ip 10.142
# more Require not lines

EDIT

The above needed to be put inside <RequireAll> tags:

<RequireAll>
    Require all granted
    Require not ip 10.142
</RequireAll>
hjpotter92
  • 78,589
  • 36
  • 144
  • 183
anubhava
  • 761,203
  • 64
  • 569
  • 643
  • 1
    It still shows an error: `AH00526: Syntax error on line 22 of /usr/local/apache2/conf/myown.conf: negative Require directive has no effect in directive` – hjpotter92 Jan 26 '14 at 13:38
  • 3
    If you search for that error message, you find, among other things: https://issues.apache.org/bugzilla/show_bug.cgi?id=53069 – larsks Jan 26 '14 at 13:39
  • Read more about Require syntax here: http://httpd.apache.org/docs/2.4/mod/mod_authz_core.html#require and see **`Syntax: Require [not] entity-name [entity-name] ...`** part I didn't suggest `RequireAny` – anubhava Jan 26 '14 at 13:41